PDA

View Full Version : Suppress single click handling for a onDoubleClick( ) event (5E ruleset)



Minty23185Fresh
December 2nd, 2018, 16:53
I'm working on an extension to implement the Druid's Wild Shape feature.

The extension modifies the Druid's character sheet statistics when an NPC is dragged on to the Portrait control.

The Portrait control has onDragStart(), onDrop(), onClickDown() and onClickRelease() event handlers. Single click handling brings up token selection so the user can choose a portrait for their character.

I have added an onDoubleClick() function to revert from Wild Shape (NPC) statistics back to the Druid's statistics.

Everything is working great except this: the double click fires both the single click and double click handlers. So when I double click the Portrait control, the statistics revert but it also brings up token selection.

I have tried the various remedies suggested in the forums (a single/double click flag) but have failed to implement them correctly, I guess, or they don't quite fulfill my needs. Searching the 5E and CoreRPG code has also been fruitless. There are coexisting single and double click handlers, but it appears as though they allow the single click handling for the double click (typically just placing a cursor in a text field followed by the double click functionality). I need to suppress the single click handling.

(The pertinent code is in <template name="portrait_char"> in the campaign/template_char.xml file)

Any help you can lend, is greatly appreciated.

[EDIT:]
I thought I found the "Finder's Stone" but alas, not, whether the onDoubleClick() returns true, false, or nil does not remedy my problem.

Moon Wizard
December 2nd, 2018, 20:29
Unfortunately, there is no way to tell whether a user click is a single click or a double click, until the second click either happens or doesn't. Therefore, the first click is treated as a single click, even if the second click is treated as a double click.

JPG

Minty23185Fresh
December 2nd, 2018, 22:20
Thank you Moon Wizard. Not particularly pleasing tidings, but we all have to play with what comes up on the dice. :)

I guess I'll go with a context menu (right-click) instead.