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
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