Thread: Cycler
-
May 4th, 2024, 11:24 #11
OK, now what I would like to do is to have a button_stringcycler whose value is saved on the DB. There must always be a value on a field of the DB. I declared it wirhout the sourceles tag.
Code:<button_stringcycler name="mycycler"> <anchored width="60"> <left parent="mylabel" anchor="right" offset="10"/> <top parent="mylabel" /> </anchored> </button_stringcycler>
Code:myValues="one|two|three|four|five"
Code:mycycler.initialize(myValues, myValues); or mycycler.initialize(myValues, myValues, nil); or mycycler.initialize(myValues, myValues, ""); or mycycler.initialize(myValues, myValues, nil, "one"); or mycycler.initialize(myValues, myValues, "", "one"); or mycycler.initialize(myValues, myValues, "one");
- have the value initialized with the db value ("one") - I've already tried to use Code:
mycycler.setStringValue("one")
- hide the empty value
A can remove "one" from the intial values/labels, but I still have no good result.
- have the value initialized with the db value ("one") - I've already tried to use
-
May 4th, 2024, 11:37 #12
-
May 4th, 2024, 14:05 #13
Ok, here is my solution. In this way I always have a field (and a value) on DB and I've no empty string shown.
Template
Code:<template name="mybutton_stringcycler"> <button_stringcycler> <script file="common/scripts/mybutton_stringcycler.lua" /> <sourceless/> </button_stringcycler> </template>
Code:local _nodeRecord; function onInit() _nodeRecord = window.getDatabaseNode(); if super and super.onInit() then super.onInit(); end end function onValueChanged() DB.setValue(_nodeRecord, self.getName(), "string", self.getValue()); end
Code:<mybutton_stringcycler name="mycycler"> <anchored width="60"> <left parent="mylabel" anchor="right" offset="10"/> <top parent="mylabel" /> </anchored> </mybutton_stringcycler>
Code:local _nodeRecord; function onInit() _nodeRecord = window.getDatabaseNode(); myValues="two|three|four|five"; mycycler.initialize(myValues, myValues, "one"); mycycler.setStringValue(DB.getValue(_nodeRecord, "mycycler", "one"); end
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks