-
October 22nd, 2020, 19:36 #1
Do onUpdate and onChildUpdate work for formattedtext nodes?
I am coding an extension for Fantasy Grounds (Classic, but I don't think the difference matters for this issue) that sits atop the GURPS ruleset, which is in turn based upon the CoreRPG ruleset. I am trying to detect changes on a formattedtext node contained within various objects contained within list nodes, e.g.:
Code:function onInit() DB.addHandler("charsheet.*.abilities.skilllist.*", "onChildUpdate", onSkillUpdooted); end function onSkillUpdooted(nSkill) ChatManager.SystemMessage("Aww yiss, I caught an update!"); end
Code:<root> <charsheet> <id-00001> <abilities> <skilllist> <id-00001> <!-- buncha nodes --> <text type="formattedtext"> <h>Butt-Kicking (DX/VH)</h> <p>Its dangerous to go alone, take this skill with you</p> <linklist> <!-- links are here --> </linklist> </text> <!-- moar nodes -->
Code:function onInit() DB.addHandler("charsheet.*.abilities.skilllist.*", "onChildUpdate", onSkillUpdooted); DB.addHandler("charsheet.*.abilities.skilllist.*.text.*", "onChildUpdate", onSkillTextUpdooted); end function onSkillUpdooted(nSkill) ChatManager.SystemMessage("Aww yiss, I caught an update!"); end function onSkillTextUpdooted(nUpdatedRun) ChatManager.SystemMessage("Tarnation! This never fires! Whyyyyyyy?"); end
Code:DB.addHandler("charsheet.*.abilities.skilllist.*.text", "onUpdate", onTheOffChanceThisWorks); DB.addHandler("charsheet.*.abilities.skilllist.*.text", "onChildUpdate", onTheOffChanceThisWorks); DB.addHandler("charsheet.*.abilities.skilllist.*.text.*", "onUpdate", onTheOffChanceThisWorks);
I wish my wife looked at me the same way that I look at my GURPS books.
-
October 22nd, 2020, 21:15 #2
function onInit()
DB.addHandler("charsheet.*.abilities.skilllist.*", "onChildUpdate", onSkillUpdooted);
DB.addHandler("charsheet.*.abilities.skilllist.*.t ext", "onUpdate", onSkillTextUpdooted);
end
Have you tried it this way instead?
Edit: I see that was one of the options. The one I have bold should do the trick. Since text doesn't have a child node the onChildUpdate won't work directly with the text node. The best location for onChildUpdate would be with the "charsheet.*.abilities.skilllist.*" set you showed. Since this has child nodes it will 'listen' to when these are changed and fire the script. I'm not sure if this is directly related to it being a formattedtext element or not, but might be as I never really have attempted to listen for changes in a formattedtext element.Last edited by superteddy57; October 22nd, 2020 at 21:23.
Dominic Morta
Ruleset Developer
Smiteworks
How to zip up your campaign if the Developers ask for it-How to zip up your campaign if the Developers ask for it
How to provide an Unity Connection issue?-Connection Issues and What to Provide
Unity Updater issue?-Updater Issues
Classic and Unity Port Forwarding?-Fantasy Grounds Connections Explained
Comcast or Cox ISP User?-Comcast XFinity and Cox Users
Have a suggestion?-Feature Request
-
October 22nd, 2020, 22:58 #3
I have attempted your suggestion and failed successfully
This page (it might no longer be valid) mentions that it is not bound to a database node.
https://www.fantasygrounds.com/refdo...extcontrol.xcp
I can almost hear Adam Savage in the background saying "Well, there's your problem!"
I did do some rigging to see if the node was being updated at runtime (by capturing the parent (skill) node and calling a getText() on its "text" node. It's definitely getting pushed to the DB, I'm just straight up not getting notified about it.
Having this work isn't a "must have" to pull off what I am trying to do, but it would be a lot cooler if it did.I wish my wife looked at me the same way that I look at my GURPS books.
-
October 23rd, 2020, 09:50 #4
That is still correct.
A "control" is not linked to database data, but a "field" is. This is a key piece of FG terminology. So, the formatted text "field" is what stores data in the database: https://www.fantasygrounds.com/refdo...dtextfield.xcp
That probably doesn’t address your issue, but it hopefully explains some terminology and the documentation.Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
October 23rd, 2020, 11:30 #5
Thank you for the clarification. As for this issue, is there another place where I should leave a bug report for it? I also have FGU, but I haven't moved my work over to it to see if the bug is there too.
I wish my wife looked at me the same way that I look at my GURPS books.
-
October 23rd, 2020, 21:12 #6
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,539
I just investigated this. It will work in FGU, but not FGC.
It was by design in FGC by the original developers (before my time) based on the way formatted text fields are implemented and dealing with performance. With FGU, it was completely rebuilt, and the proposed solution will work (in FGU only). Unfortunately, there is no easy way to make this work in FGC without rewriting whole portions of formatted text fields; and there are no plans to spend that much development time on FGC given FGU work.
The workaround is to use the onValueChanged event in the formattedtextcontrol/formattedtextfield to capture the changes; and apply whatever actions you want.
Regards,
JPG
-
October 24th, 2020, 12:35 #7
Ah ha! Thank you! It's almost time to move, then
I wish my wife looked at me the same way that I look at my GURPS books.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks