I initially came up with this trick, its actually one of the first code tricks I introduced into the community a loooong time ago.... and I also abandoned it again for another trick, with the same results, but 'safer'
Fitst of I created a small drop in which can help you use this onMouseOver event, you can find the link on how to use it in my signature and a small wiki article I wrote: onMouseOverEvent
Second: the trick for which I swapped this one is the (actually existing) onChangeSelection
. To use this you will need a form active, this can be an info box, a character sheet, or in my case: token related macros. The trick then is simple:
1. first you need a token property (preset in the settings) e.g. 'initialize:1'
2. in the form you need one line
<link rel='onChangeSelection' type='macro' href='macroLink'>
where 'macroLink' is an actual macro link to a macro.
3. the macro is run EVERY time you select on a token (thus also when you just click on it). In my case I check the token property set of the token e.g. 'vehicle' and then redirect the macro to another macro that builds the form with macro buttons specifically for vehicles. To start the 'token initializer' you simply need a couple of lines of code:
<!-- make sure only one token is selected -->
[me = getSelected()]
[abort(listCount(me) != 1)]
<!-- make that token currentToken -->
<!-- if the token has not been initialized, do so now -->
In the 'initializeToken' you obviously need to set 'initialize = 0' or the macro will be invoked every time you select the token.
This boils roughly down to the method using the onMouseOverEvent, but this is more stable.