Touch Selection on mobile fires move event - fabricjs

When selecting an object on a mobile device with a touch a move event is instantly fired and the object shifts.
Is there a way do set a delay on these touch selection events so that a user must either hold the object for a few milliseconds before dragging or had to select the object a second time to drag?

Related

General Application Design - Events + Async

I have an issue with designing my application.
On my login form, I fire off an event in my ViewModel that's handled in the View (it displays a progress bar).
Then I query the database
Based on the query result I fire off an event from my ViewModel whose handler displays a message based on the result
The problem is when the query executes so fast that the (async) event handler doesn't even get to initialize the progress bar before the second event gets fired. The second event handler registers that there are no progress dialogues open so it doesn't try to close the open one before displaying the message. And when the user acknowledges the message, he is left with a indeterminate progress dialog which blocks the rest of the UI.
What design pattern should I utilize to avoid this race condition?

How to identify event is being called from Secondary tile

When I run my Windows 8 application it creates a primary tile and a secondary tile.
If I click on the primary tile it should open a URL. Clicking on the secondary tile should not open the URL and instead just a splash screen, so I added Window.Current.VisibilityChanged += Window_VisibilityChanged; to capture the event. But this gets called when you click on both tiles.
How do I find out if the event is triggered from the primary or secondary tile?
Another thing I noticed is if I click on the secondary tile it first hits the window_VisibilityChanged and also goes through the onLaunched method of App.xmal.cs.
Is there a way to figure out if the event is being fired from secondary tile before it hits the onLaunced method?

Intercept (and perhaps cancel) page's mouse/keyboard event handlers

I'm trying to create a Chrome Extension that deals with selected text. Some website pages' otherwise selectable text content has click/mouse-up/down event handlers that navigate to a new page.
Is there a way from the background or content script to temporarily disable (and restore) the page's arbitrary event handlers without interfering with the native text selection?
Worst case I'm thinking of is to detach, clone the body html, allow the selection, and then restore the bound original. Seems like trouble.
Thanks!
Most HTML DOM events follow the capture-target-bubble event model. This means, for example, that if you click on a button, that the "click" event is first dispatched at the root, all the way down to the button, then back up. Event propagation can be stopped, which prevents the event listener at the next level from being notified of the event.
The earliest possibility of receiving the event is at the root, often window at the capture phase. To bind an event listener to the capture phase, use addEventListener with the third parameter set to true:
// in a content script, at run_at:document_start
window.addEventListener('click', function(event) {
event.stopImmediatePropagation();
}, true);
Many web pages use jQuery to manage DOM events, which binds the event listeners at the bubbling phase, so the previous method will work on most sites. If the page does not use jQuery, then you have to bind your event listener at document_start to make sure that your event listener is triggered before every other event listener.

Cocoa: Delaying one method call until a subsequent call is processed

I've found myself in the following situation: I've got an NSTableView subclass with an active cell. when I click elsewhere on the user interface, the delegate method (i) is fired, this in turn fires (ii) (my own method) cocoa then proceeds to process the click, resulting in the final two calls. I was surprised and disappointed by this sequence, since I had assumed the mouse click would be the first rather than the last event processed. It also causes me a problem because the ideal implementation of manageState is dependent on some of the processing I do in mouseDown:, but of course when manageState is called mouseDown: has not yet been executed.
Is their a way to delay the execution of manageState until mouseDown has returned? For example, in manageState I'd say something like Stop! a mouse down event might be in the events queue. Wait until it's finished, then resume. As the previous sentence implies, it's also possible that this method could be triggered by something other than a mouse down. In this situation, there's no need to look out for a mouse down event and processing can continue as normal.
MOUSE CLICK on NSTextView while NSTableView cell has focus...
+-------------------------+--------------------------------------------------------+
|Event |Triggered because |
+=========================+========================================================+
|controlTextDidEndEditing:|The mouse click ends the editing session |
| |of the active cell in my table view |
+-------------------------+--------------------------------------------------------+
|manageState |This method is a selector that belongs to a notification|
| |that is fired from within controlTextDidEndEditing: |
+-------------------------+--------------------------------------------------------+
|becomeFirstResponder |I clicked on the NSTextView instance |
+-------------------------+--------------------------------------------------------+
|mouseDown: |Finally, the click that started it all is processed |
+-------------------------+--------------------------------------------------------+
I figured this one out for myself. I feared I'd have to cobble together a threads-based solution, but a bit more docs-scouring turned up the NSEvent class method addLocalMonitorForEventsMatchingMask:handler.
When my app starts I call this method, define the associated block, and 'tell' the method what events I want to look out for. Then, whenever one of these events is detected, the block runs. Crucially ,this happens before any of the processing precipitated by the event is set in motion. In the block you have the opportunity to stop the event in its tracks, or let processing continue, you also have access to the event itself . Going back to my question, this means I am effectively inserting an additional row at the top of the table. This was perfect since it allows me to act on the event before any of the subsequent event executes.
[NSEvent addLocalMonitorForEventsMatchingMask:NSLeftMouseDownMask
handler:^NSEvent *(NSEvent *event) {
// whenever an event of type NSLeftMouseDownMask is detected, this code
// will run before any other event processing
// do some processing, then...
return event; // or nil, if you want to block the event
}];

minimize and getting back the display

I want to minimize my app and after the timer end get it back.
I use code below.
To minimize application use following line of code:
Display.getDisplay (MIDLET_CLASS_NAME).setCurrent (null);
To get the screen back use the following:
Display.getDisplay (MIDLET_CLASS_NAME).setCurrent (myCanvas);
But when phone display is dismissed and going to clock mode my midlet display isn't shown until press any button.
any idea?
From your question it sounds that you expect setCurrent to somehow "force" device to immediately display your screen or maybe return only after screen gets visible.
This is not so, as clearly explained in the API documentation for Display.setCurrent:
Requests that a different Displayable object be made visible on the display. The change will typically not take effect immediately. It may be delayed so that it occurs between event delivery method calls, although it is not guaranteed to occur before the next event delivery method is called. The setCurrent method returns immediately, without waiting for the change to take place...
...if the application is in the background, passing a non-null reference to setCurrent may be interpreted by the application management software as a request that the application is requesting to be brought to the foreground... These are only requests, and there is no requirement that the application management software comply with these requests in a timely fashion if at all...
Consider redesigning your MIDlet to adjust to specified behavior.
If myCanvas is an instance of Canvas, one can use showNotify() events.
For a generic Displayable screen isShown() method checks if the it is actually visible on the display.
Sometimes it could even make sense to let user explicitly confirm return from background, like
display.setCurrent(new Alert("back to foreground", "dismiss to continue...",
null, AlertType.INFO), myCanvas);

Resources