Thread: Conditional hiding (control)
-
September 4th, 2022, 20:06 #1
Conditional hiding (control)
Sorry for the not-programmer language ahead!
Within the confines of a window-within-a-window I have a button that does this:
Code:function onClickDown() local nodeWin = window.getDatabaseNode(); local XP = nodeWin.getChild("skill_xp").getValue(); local XPpay = nodeWin.getChild("skill_xptolvl").getValue(); local XPnew = XP-XPpay; nodeWin.getChild("skill_xp").setValue(XPnew); end function onClickRelease() local nodeWin = window.getDatabaseNode(); local nSkill = nodeWin.getChild("skill_current").getValue(); local nSkillnew = nSkill+1; nodeWin.getChild("skill_current").setValue(nSkillnew); end
Now, I want to hide the button, making it accessible only if the current skill_xp value exceeds or equals the current skill_xptolvl value. But is that at all possible?
-
September 4th, 2022, 21:04 #2
One of many solutions:
- Add the xml tag <invisible /> to the button.
- Add this pseudocode to skill_xp
Code:function onValueChanged() local nXP = getValue(); local nCurrentXP = path_to_node.getValue(); if nXP >= nCurrentXP then path_to_button.setVisible(true); end end
If your data is saved to the DB, it's advised to directly call the DB with DB.getValue() and DB.setValue().
See here for more information: https://fantasygroundsunity.atlassia...s/996644582/DBGitHub
Ruleset: FFd20
Extensions: Advanced Charsheet - Attack Modifiers - Big Portraits - Enhanced Skills - Legacy Items - Spell Action Info - Spell Record Actions - Tooltips
-
September 5th, 2022, 09:35 #3
-
September 9th, 2022, 08:10 #4
Having read and re-read the wiki and how
getPath()
specifically:
function onValueChanged()
local nodeWin = window.getDatabaseNode();
local XP = nodeWin.getChild("skill_xp").getValue();
local XPpay = nodeWin.getChild("skill_xptolvl").getValue();
local XPinc = nodeWin.getChild().getPath("button_skill_increase" );
if(XP>=XPpay) then
XPinc.setVisible(true);
end
endLast edited by Lillhans; September 9th, 2022 at 08:17.
-
September 9th, 2022, 15:59 #5
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,559
You're mixing the concepts of database interactions with UI object interactions. The button_skill_increase is a UI control, not a database node.
If I was going to write similar code, I would write like this:
Code:function onValueChanged() local node = window.getDatabaseNode(); local nXP = DB.getValue(node, "skill_xp", 0); local nXPToLevel = DB.getValue(node, "skill_xptolvl", 0); local bShowIncButton = ((nXPToLevel > 0) and (nXP >= nXPToLevel)); window.button_skill_increase.setVisible(bShowIncButton); end
For both skill_xp and skill_xptolvl fields, add:
Code:function onValueChanged() window.onSkillXPUpdate(); end
Code:function onSkillXPUpdate() local node = getDatabaseNode(); local nXP = DB.getValue(node, "skill_xp", 0); local nXPToLevel = DB.getValue(node, "skill_xptolvl", 0); local bShowIncButton = ((nXPToLevel > 0) and (nXP >= nXPToLevel)); button_skill_increase.setVisible(bShowIncButton); end
JPG
-
September 10th, 2022, 13:41 #6
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks