-
September 12th, 2020, 01:36 #1
- Join Date
- Aug 2019
- Location
- Australia
- Posts
- 31
Best way to have an "active" checkbox in a list.
I have added a checkbox to a list to allow the user to pick which weapon is active. See:
Screen Shot 2020-09-12 at 12.24.55 PM.png
When the user clicks on one of the checkboxes, I have written the code to turn the others off.
Code:<button_checkbox name="active_weapon"> <tooltip text="Click to make this the active weapon" /> <script> <![CDATA[ function onValueChanged() local name = DB.getValue(window.getDatabaseNode(), "name"); local active = getValue() == 1; if active then Debug.console(name .. " is the active weapon."); for _,v in pairs(window.getDatabaseNode().getParent().getChildren()) do if DB.getValue(v, "name") ~= name then DB.setValue(v, "active_weapon", "number", 0); end end end end ]]> </script> </button_checkbox>
-
September 12th, 2020, 10:10 #2
Looks like a tidy approach to me, but I'm no code guru
Cheers, Steve.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks