Thread: Options Sheet Text Box
-
July 7th, 2021, 06:19 #1
- Join Date
- Mar 2020
- Location
- Sydney, Australia
- Posts
- 247
Options Sheet Text Box
Hi,
I have successfully created a textbox control in the Options sheet.
However, no matter how hard I try can I get an onValueChanged callback to trigger.
The internal onValueChanged seems to trigger, however the one I registered while registering the Option does not.
I am pasting relevant code here.
The Option control I created...based on the Cycler layout.
Code:<?xml version="1.0" encoding="UTF-8"?> <root> <windowclass name="option_textbox"> <margins control="0,0,0,2" /> <script> local sOptionKey = nil local sDefaultValue = "" local enable_update = true function onClose() end function onOptionChanged(sKey) end function setLabel(sLabel) label.setValue(sLabel) end function setReadOnly(bValue) textbox.setReadOnly(bValue); end function initialize(sKey, aCustom) sOptionKey = sKey if sOptionKey then if aCustom then sDefaultValue = aCustom.baseval or "" end setTextValue(OptionsManager.getOption(sOptionKey)) end end function onHover(bOnWindow) if bOnWindow then setFrame("rowshade"); else setFrame(nil); end end function getTextValue() local sValue = textbox.getValue() if sValue == "" then sValue = sDefaultValue end return sValue end function setTextValue(sValue) enable_update = false if sValue == sDefaultValue then sValue = "" end textbox.setValue(sValue) enable_update = true end function onValueChanged() if enable_update and sOptionKey then Debug.chat("New Value -> "..getTextValue()) OptionsManager.setOption(sOptionKey, getTextValue()); end end </script> <sheetdata> <stringcontrol name="label"> <anchored> <top offset="5" /> <left offset="15" /> <right offset="-135" /> </anchored> <font>optiontitle</font> <static /> </stringcontrol> <stringcontrol name="textbox"> <anchored width="100"> <top offset="5" /> <left parent="label" anchor="right" offset="25" /> </anchored> <center /> <font>optionbody</font> <script> function onValueChanged() window.onValueChanged(); end </script> </stringcontrol> </sheetdata> </windowclass> </root>
Code:OptionsManager.registerOption2( key, true , group, label, "option_textbox" , { baselabel = value , baseval = Interface.getString(value) , default = Interface.getString(value) } ) OptionsManager.registerCallback(key, callback) <--- this is the callback that does not seem to fire (I have debugs in that function to announce the firing).
Thanks In Advance,
D
-
July 7th, 2021, 10:47 #2
- Join Date
- Mar 2020
- Location
- Sydney, Australia
- Posts
- 247
I have solved the problem ... seems I had a single character typo in my scripting and thus it was failing to find the correct callback function.
Thanks In Advance,
D
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks