Post subject: Wolph42's drop in onMouseOverEvent (advanced)
Posted: Mon Apr 18, 2011 7:05 am
Recently there was a discussion over the possible events in MT like onTokenMove, onSelectionChange, etc. These are officially supported by MT. There is however one event that is not officially supported but is available if you know how to implement: onMouseOver. The implementation is a pain and it has taken me about 4 hours of testing to get this right. The problem is not to trigger the event, the problem is to trigger the event AND you want to use the input() function. Using input() icw this trick will haywire MT, unless you do it right.
I've created a lib token with two types of events, one that runs only once after you drag a new token onto the map. And one event that triggers every time you mouseover a DIFFERENT token.
The below instructions can be found in the 'Notes' of the lib token attached. To get this working, download the token, drag/drop it into you campaign file, follow at least the first 5 lines of instructions (but do read the rest, cause there are some catches) and you're golden.
For each type of event there are two macro's, one which is triggered on that event and one that is called by the triggered macro. The latter ends its name with 'Macro' and these are the macros that you can edit with you own code.
Make sure that the 'Show stat sheet on mouse over' is turned on: menu--> edit --> preferences --> Interactions --> 'tokens' box: at the bottom --> check the checkbox
Add the following two lines to the Basic property set:
The property set can be set here: menu--> edit --> Campaign Properties --> Token Properties --> Basic --> copy the lines --> Update --> OK
You can edit the two macro's that end with 'Macro'. Here you can put in code you like to have executed.
Note that: - if you use a different set for your tokens that you need to set the properties for that set - if you only want to use the 'run once event' (onMouseOverOnceVar) or the 'run every time I hover over event' (onMouseOverPermanentVar) or both, add the lines correspondingly. - the 'run once event' has a selectTokens() command that will select the token hovered over. This can be removed - the 'run every time event' doesn't have a selectTokens() command, but you can add it if you like. - If you 'cancel' the 'run once event' it will be triggered a 2nd time. Not sure why. If you however click 'ok' then it will run only once. - There are two optional macros on this lib token. These you can use to either fix an onMouseOver event for the 'every time' type if its broken. Or reset the 'run once event' to run again. To Use: Just drag the macros to the campaign panel, select the token and run the macro. - If the permanent event is broken for ONE token, it won't work anymore for ANY token!!! - One way to break this is by copying a selected token. The copied token won't trigger the onMouseOverEvent. This is because as soon as you hover over a token the macro call is deleted and only restored if you hover of another token (that has that macro call active). The token ID of the last token that activated the event is stored in the lib. The ID's of the copied tokens however are unknown to the library. The only way to get those working is by using the 'resetPermanentEvent' macro.
(can be also found in the 'Notes' section of the library token)
Post subject: Re: Wolph42's drop in onMouseOverEvent
Posted: Mon Apr 18, 2011 7:34 am
Forgot to mention: I've added a function that replaces the 'show dialog on new token', which allows the user a lot more versatility. This is also worth checking out. It makes use of one of the two events. Obviously you need to turn the show dialog off, this can also be found in the preferences.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
Who is online
In total there are 2 users online :: 1 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes) Most users ever online was 243 on Sun Nov 04, 2012 6:14 am
Users browsing this forum: Alexa [Bot] and 1 guest