PDA

View Full Version : Token selection timing, select after double-click



anathemort
January 20th, 2022, 00:34
Following up on my post from yesterday about working on double-click to target (https://www.fantasygrounds.com/forums/showthread.php?72236-Overridden-onDoubleClick-still-calling-CoreRPG-onDoubleClick), I am now attempting to select the active token after completing the double-click. As I complete the "set target," I have the owner look up their token's active window and select it. This process works when there are no clicks involved (I use the same function when moving between turns, to auto-select the active token), but with a double-click, it becomes apparent that the timing of mouse click handling is in play here. I'm pretty sure this is just not practicle to fix, but maybe there is a trick I don't know about!

You can see a video of it in action here:
https://www.loom.com/share/0cbe7a8e0508435789041c99785c03fc

And the relevat select-self code:

function toggleSelectedToken(bSelect)
local nodeActive = CombatManager.getActiveCT();

if not DB.isOwner(nodeActive) then
return;
end

local nodeCT = CombatManager.getTokenFromCT(nodeActive);
local container = ImageManager.getImageControl(nodeCT, false);
Debug.chat('rcv token select', bSelect, nodeActive);

if nodeCT and container then
container.clearSelectedTokens();
container.selectToken(nodeCT, bSelect);
end
end

Moon Wizard
January 20th, 2022, 00:42
At this point, I don't think it's something that we will be looking at adjusting. Any time you change the ordering of triggers/scripts, you can have unintended knock-on effects to existing behaviors.

My guess is that the actual token "selection" updating is happening after the script; but I would have to go rooting around in the code that @cpinder maintains (and he is currently away for a bit).

Regards,
JPG

anathemort
January 20th, 2022, 00:49
Fair enough. I know it's a funky thought, but there's no way to callback after a delay in FG, is there? I could see postponing the self-select for 100ms or something goofy like that. Part of me hopes the answer is no :D

Moon Wizard
January 20th, 2022, 17:36
No, that would require a whole event tracking system that works differently than it works before. I know that there are several scripts that are dependent on events happening inline with UI actions and API call events.

Regards,
JPG