-
February 12th, 2021, 15:44 #1
[MoreCore] CAS, etc - How to make P1 input <delaykeyupdate /> of sorts?
I added code to recalculate HP based on any change +- in Con bonus if Constitution was changed. Previously, if I changed con, it only used the new value in future rolls (including applying for all HD previously rolled)
This works, but as in other number input controls I worked with like pc level - it triggers a change each time a digit is typed. For PC Level, I added the <delaykeyupdate /> tag and this resulted in on onValueChanged() only being called on hitting enter or the control losing focus.
I played around first, while not loaded, I changed a specific PC's con on both the campaign db (below) and mod (next code section) to include " <delaykeyupdate />". But no love, it still prints:
Code:Character's hitpoints changed from 38 to 30 (Constitution changed from 11 to 1)
Any tips, things to look at?
(From the campaign db.xml: )
Code:... <cas> </cas> <charsheet> <id-00001> <aac> ... <clilist1> <cha> ... </cha> <con> <alt_sort_order type="number">5</alt_sort_order> <clichatcommand type="string">/mod 0</clichatcommand> <delaykeyupdate> </delaykeyupdate> <description type="formattedtext"> <p>Constitution</p> </description>
Code:... <reference static="true"> <cas> <category name="Attributes" baseicon="0" decalicon="0"> <str> ... </dex> <con> <alt_sort_order type="number">5</alt_sort_order> <clichatcommand type="string">/mod 1</clichatcommand> <delaykeyupdate /> <description type="formattedtext"> <p>Constitution</p> </description> <locked type="number">1</locked> <name type="string">Constitution</name>
Last edited by Varsuuk; February 12th, 2021 at 15:50.
-
February 12th, 2021, 19:38 #2
I added a "workaround" to eliminate at least calling my watcher method when the value is < 3 for Con:
Code:function updateConstitutionScore(node) local nodeChar = nodeCharFromAttributeScore(node) local nNewConstitution = getAttribute(nodeChar, Interface.getString("attributes_constitution_id")) if nNewConstitution < 3 then -- Workaround until I can get updated only on enter/lose-focus :( return end if nCurrentConstitution ~= nNewConstitution then local _, sPCClassRecord = DB.getValue(nodeChar, "pcclasslink") ...
I did this when I realized that the calling into my method is via a watcher I setup. It watches the DB entry. So, if I cannot stop the DB from being updated until ENTER/Lose-Focus - I can at least ignore some updates. Still would like to do it via the delay update thing
Code:local nCurrentConstitution = 0 function registerConstitutionWatcher(nodeChar) Debug.console("nodeChar=", nodeChar) local sAttributePath = getAttributePath(Interface.getString( "attributes_constitution_id")) DB.addHandler(DB.getPath(nodeChar, sAttributePath), "onUpdate", updateConstitutionScore); end
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks