Filter events globally in KONVAJS - events

Is it possible (e.g. by overwriting a prototype) to filter (enable/disable) events globally in KONVA?
use case:
I have an interactive app built with KONVA. At the beginning, I want to show a "demonstration" of the user interface: I'm displaying a moving second mouse cursor and fire events which are handled by the app to demonstrate possible interactions. All is working, but during the demonstration, the app should not listen to real mouse events, only to the simulated ones (having a special property set in event object).

For that use case, just set listening: false for your stage. It will disable ALL events on the stage and its children.
You can turn off events just for demonstration. As soon as it is done, you can turn mouse/touch/pointers events on with listening: true.

Related

Monitor Appointment Cancel Event

I am trying to run some code upon cancellation of an AppointmentItem, however two of the events that I tried to capture fire more than once (Application.Send, AppointmentItem.Write, BeforeDelete doesn't fire). This bring me to re-think my logic and find a suitable place to implement it. I couldn't find a reason why the two events are fired twice in my case as I am using inspector wrapper to register these events on a new inspector window and Un-registering them on inspector close event.
Please note that I want to monitor all possible scenario where an Appointment can be canceled/deleted.
Why do you even need any inspector events? Monitor the Application.ItemSend event, check if you get a MeetingItem object as an argument, check that the message class is "IPM.Schedule.Meeting.Resp.Neg" or Class = 55 (OlObjectClass.olMeetingResponseNegative).

block ALL keyboard access, mouse access and keyboard shortcut events

In order to block ALL keyboard access, mouse access and keyboard shortcut events in one of my projects, I:
Created a full screen transparent borderless window, in front of other windows, but invisible.
Handle all keyboard and mouse events with simple return; the window itself.
Make the window modal [NSApp runModalForWindow:myWindow] in order to block keyboard shortcuts.
Release window from touchpad's gesture events only.
But this guy made it look simple in a tiny app -MACIFIER:
How did he do it?
not really sure if this would be usable, but you could use the program hotkeynet (generally used for gaming, but I have had success using other methods) and map every single key/mouse action to do nothing. I did something similar by blocking access to a specific program with it in about 20-30 minutes.
not sure if it will help; but it might be the solution you need?
I believe you can use Quartz Event Services. In particular, have a look at CGEventTapCreate, and note the 4th parameter, which allows you to specify what kinds of events you'd like to intercept. The available kinds of events are listed in the CGEventType enum.
If you set your tap to be an active filter, returning NULL from the callback will delete the event.

Safari extension context menu item command event is firing twice

I have developed an extension for Safari which uses a context menu.
In the code, I am listening to the command event of the context menu item using:
safari.application.addEventListener("command", commandHandler, false);
In the commandHandler() function, I have added an alert statement for debugging purposes. By doing so, I found that the function commandHandler() is firing twice whenever I click on the context menu item.
Also I added a tool bar item, which also fires the command() event on clicking. The function attached to the command() event is also firing twice after clicking on the item.
Does anybody know of this issue and how to resolve it?
Without more information, this sounds like a problem of insufficient filtering. That is, you're receiving all command messages without determining which they are or why they're flowing across your callback layer, and your callback layer receives two messages per click of, as given, unknown disposition.
The event notification callback structure for Safari extensions allows you to register multiple events against the same event type, and multiple distinct events may be generated in many cases. To this end, your attempt to add an event listener to the "command" scope means you're literally receiving all commands passed to the callback layer. These may be multi-firing in cases where you have, for example, a complex nesting relationship (A contains B, where A and B both notify) or a complex behavior pattern (for example, a mousedown followed by a mouseup).
Apple provides guidance on how to handle this scenario, by binding the command to a specific target or specific command, which is what you should do here. And just in case that's insufficient, here's additional documentation on how the callback system works to help you define your events properly.
Following the guidance should allow you to work through this issue by properly binding your events to your object and only operating on the events you need. Everything else should simply be ignored by your event handler.

LWUIT tactile device issue

I need to capture the event that an app throws when you click on the screen, on a list. When I click on the screen, actionPerformeed(ActionEvent e) returns -1, I suppose that it is the default event.
In non-touch devices, the launched event by pressing the central button is Canvas.FIRE, why not in tactile devices?
How can I do that?
The actionEvent source argument will be from the list. Action events are designed to encapsulate the trigger for the action (e.g. key/touch) since that is irrelevant. There is no need to distinguish the trigger since you can always extract the lists selected item and use that.
There are use cases where one would like to know the location touched within the cell renderer but that is a special case unrelated to the question.

How flash dispatchEvent really works?

It is said in the docs, that EventDispatcher's dispatchEvent "...dispatches an event into the event flow". The phrase is nice-looking and doesn't really explain anything.
Say, we have two listeners waiting for an event "A" on object "a", so what behaviour do we have to expect on calling:
a.dispatchEvent("A")?
Would both listeners be called immediately, before return from distpatchEvent? Or they will be queued in some internal flash player queue and will be processed by entering the next frame? Can we rely on some defined behaviour of flash player here or the behaviour is undefined? How one should read "dispatches an event to event flow"? The question is important since in practice it affects the control flow of the code.
It all depends on your display list hierarchy.
Flash's event structure is based on its internal event model.
The Stage will be the first object
notified, and then the event will
trickle down the display list until
it reaches its target. This phase is
called the capture phase. To enable it, set useCapture to
true on an event listener. Do note
that it's pointless to do so unless
the object listening is a parent of
the object targeting the event. This
is called event intercepting.
The next phase is the target
phase. This is the behavior most
commonly known with events. The
targeted display object (the one the
has a listener for the event) will
receive the event and carry out the
code in the listener.
The final phase is called the
bubbling phase. This is when the event bubbles up the display list
after the event has been received. Event bubbling is very important for
dispatching custom events, as you'll
need to know how to listen for
events dispatched by an object's
children.
When dispatching an event, I generally use this syntax (Event.CHANGE is just a common example):
Object.dispatchEvent(new Event("CHANGE", true, false));
The Object is the object you're dispatching from. The first parameter is the event you're dispatching. The second is the bubbles parameter. The final is the cancelable property. Event.cancelable is used to prevent the default action of an event (IE: a mouse click) via Event.preventDefault().
Reference:
Chapter 21 of Colin Moock's
Essential Actionscript 3.0
EventDispatcher.dispatchEvent()
Event.cancelable
Just use Signals instead :P
https://github.com/robertpenner/as3-signals/wiki
No but really, they're very easy to use and understand, a great addition to the AS3 toolbox.
You can also learn a lot about how native AS3 events work by reading Rob Penner's critiques (scroll down to bottom of wiki page)

Resources