-
January 18th, 2022, 20:44 #1
- Join Date
- Jan 2020
- Posts
- 280
Overridden onDoubleClick still calling CoreRPG onDoubleClick
Hello,
I am attempting to muck with what happens on token double-click, effectively turning a double-click into a toggle target action. manager_token has this:
Code:function onInit() -- snipped Token.onDoubleClick = onDoubleClick -- etc end function onDoubleClick(tokenMap, vImage) -- open sheet if owner or host, etc end
Code:function onInit() Token.onDoubleClick = onTokenDoubleClick; OptionsManager.registerOption2("TFD_TDC", true, "option_header_client", "option_label_TFD_TDC", "option_entry_cycler", { labels = "option_val_on", values = "on", baselabel = "option_val_off", baseval = "off", default = "off" }); end function onTokenDoubleClick(tokenMap, vImage) Debug.chat("onDoubleClick", tokenMap); if OptionsManager.getOption("TFD_TDC", "on") then local nodeActive = CombatManager.getActiveCT(); local nodeCT = CombatManager.getCTFromToken(tokenMap); if not nodeActive or not nodeCT then Debug.chat("calling TM", nodeActive, nodeCT); TokenManager.onDoubleClick(tokenMap, vImage); else local _, sRecord = DB.getValue(nodeActive, "link"); local owner = DB.getOwner(sRecord); if DB.isOwner(sRecord) then TargetingManager.toggleCTTarget(nodeActive, nodeCT); else Debug.chat("calling TM", "not owner"); TokenManager.onDoubleClick(tokenMap, vImage); end end else Debug.chat("calling TM", "option off"); TokenManager.onDoubleClick(tokenMap, vImage); end end
-
January 18th, 2022, 20:49 #2
Return true/false. True should block the super.
---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
January 18th, 2022, 20:51 #3
- Join Date
- Jan 2020
- Posts
- 280
-
January 18th, 2022, 22:19 #4
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,412
You can't override the double-click handling in TokenManager without replacing TokenManager completely.
Token.onDoubleClick registrations are handler registrations, which any number can be registered and all will be called.
Regards,
JPG
-
January 18th, 2022, 22:22 #5
- Join Date
- Jan 2020
- Posts
- 280
-
January 18th, 2022, 22:26 #6
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,412
They are built-in "handler" registrations that are part of the FG API. Anything listed as a "handler" in the API falls into this category of a multiple registration scenario.
I've been slowly refactoring the scripts to move the handler registrations into onDesktopInit in many global scripts to allow more flexibility; but I've been doing that as I update the files for other reasons and I'm concerned with modifications that may break extensions. I don't think it will, but extension writers do some crazy stuff...
Regards,
JPG
NOTE: It looks like the "handler" tagging in the documentation got lost in the migration to the new wiki. Most handlers begin with "on...", such as "onDesktopInit", "onWindowOpened", etc.Last edited by Moon Wizard; January 18th, 2022 at 22:28.
-
January 19th, 2022, 00:20 #7
- Join Date
- Jan 2020
- Posts
- 280
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks