So I've been playing with FrontEndTokens recently and discovered that there are some of them that don't seem to have a standard-usage way of being called. For example, the "Tab" token isn't called when the tab key is pressed, but is captured by the {"MenuCommand","Tab"} event binding, which makes it ripe for abuse as a custom event. That is, if it really doesn't have a common usage, it should be possible to use it as a place holder for a function that will be performed by whatever event handlers. Tkinter in python has this sort of thing via a virtual event caller.
That led me to wondering if it's possible to construct personalized FrontEndTokens that I could use as EventHandler callbacks.
I'm afraid the answer to this is probably no, given that some of the simple test I've run (e.g. trying NotebookEventActions -> {{"MenuCommand", "CustomEvent"} :> Print[1]} haven't worked) but if this were possible it would extend the UI capabilities of Mathematica dramatically.
FrontEndTokenExecuteand a{"MenuCommand",token}. The idea is to call the event myself and have it be caught by an event handler, for example, have like"MouseClicked"and"MouseExited"callFrontEndTokenExecute["VirtualEvent"]. Basically I want to emulate the tkinter virtual event / event_generate mechanism. – b3m2a1 Dec 14 '16 at 16:39event[]andDynamicscan catch that. – Kuba Dec 14 '16 at 16:50event1[]on the"CustomEvent"call and the second could doevent2[]. This is why tkinter allows you to register virtual events. I get what you're saying, though, wondering which event handlers would catch such a call, but I figure it's the same as howEventHandlerorCellEventActionsbehave with"MenuCommand"tokens. Only event handlers with current focus should catch them. – b3m2a1 Dec 14 '16 at 17:23Dynamic[customEventSymbol; action;Spacer[0], TrackedSymbols :> {customEventSymbol}]as a "listner" and FrontEndTokenExecute translated tocustomEventSymbol++or something. – Kuba Dec 14 '16 at 18:34DynamicWrapper. Just doDynamicWrapper[eventHandlerExpr, customEventSymbol; action, TrackedSymbols :> {customEventSymbol}]. That way you can just put the expression you were going to wrapEventHandleraround in there. Obviously it also works withSpacer[0]to make an invisible listener, too. – b3m2a1 Dec 14 '16 at 19:04Dynamicmore readable, the more that they changed something and it doesn't behave asDynamic[expr; Refresh[e, None]], so it is better now, but the fact its documentation sucks repels me. – Kuba Dec 14 '16 at 19:13