Thread: StringField setUnderline()
-
October 2nd, 2011, 16:37 #1
StringField setUnderline()
I'm trying to use the setUnderline(boolean) method to underline the skill names for The One Ring. This is working fine for the common skills, where I'm using a StringCOntrol with static text. However, it doesn't seem to work with a StringField to underline the value - which I'm using for weapon skills. Is the setUnderline method meant to work with StringField objects, or does it just work with static text?
Examples:
Code:function onValueChanged() window.awelabel.setUnderline(getState()) end
Code:function onInit() setUnderline(window.awefavour.getState()) end
The weapon list item code is similar, but in an item windowclass for the weapon list. The name is also a stringfield rather than a stringcontrol.
Code:function onValueChanged() window.name.setUnderline(getState()) print("in OnValueChanged") end
Code:function onInit() setUnderline(window.weaponfavour.getState()) print("in OnInit") end
Using Ultimate license - that means anyone can play.
Valarian's Fantasy Grounds Rulesets
-
October 3rd, 2011, 00:07 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,613
The function should be identical for both stringcontrol and stringfield, based on the code. Stringfield is actually derived from stringcontrol.
You might want to set some print statements for the getState() result to see if the return value is not what you expect.
Also, you might want to check out the Debug extension on the Downloads page. Once you turn on for a ruleset, it allows you to use Debug.chat and Debug.console to pass a list of variables to the chat window or console log, respectively.
Regards,
JPG
-
October 3rd, 2011, 12:36 #3
Thanks Moon Wizard, I'll give this a go tonight
Using Ultimate license - that means anyone can play.
Valarian's Fantasy Grounds Rulesets
-
October 3rd, 2011, 18:42 #4
Looks like the cross-referencing isn't working.
The onInit in the name stringfield doesn't recognise the one weaponfavour checkbox value set. All three weapons I have in the list are coming back as false.
The onValueChanged looks right in terms of the getState in the weaponfavour checkbox, but it's not setting the underline for the name stringfield.
Code:Script Notice: in OnInit: Script Notice: false Script Notice: in OnInit: Script Notice: false Script Notice: in OnInit: Script Notice: false Script Notice: in OnValueChanged: Script Notice: false Script Notice: in OnValueChanged: Script Notice: true Script Notice: in OnValueChanged: Script Notice: false Script Notice: in OnValueChanged: Script Notice: true
Last edited by Valarian; October 3rd, 2011 at 18:45.
Using Ultimate license - that means anyone can play.
Valarian's Fantasy Grounds Rulesets
-
October 3rd, 2011, 19:39 #5
It's not making any more sense, even with Debug.
I've added these lines to the code:
Code:Debug.console(window) Debug.console(window.name) Debug.console(window.weaponfavour)
Code:Runtime Notice: Reloading ruleset Script Notice: in OnInit: Script Notice: false Script Notice: WINDOWINSTANCE = { class = charsheet_weaponlistitem, node = charsheet.id-00001.weaponlist.id-00001, x,y,w,h = 0,0,0,0 } Script Notice: STRINGCONTROL = { value = Bow, x,y,w,h = 0,0,0,0 } Script Notice: WINDOWCONTROL = { nil } Script Notice: in OnInit: Script Notice: false Script Notice: WINDOWINSTANCE = { class = charsheet_weaponlistitem, node = charsheet.id-00001.weaponlist.id-00002, x,y,w,h = 0,0,0,0 } Script Notice: STRINGCONTROL = { value = Short Sword, x,y,w,h = 0,0,0,0 } Script Notice: WINDOWCONTROL = { nil } Script Notice: in OnInit: Script Notice: false Script Notice: WINDOWINSTANCE = { class = charsheet_weaponlistitem, node = charsheet.id-00001.weaponlist.id-00003, x,y,w,h = 0,0,0,0 } Script Notice: STRINGCONTROL = { value = Dagger, x,y,w,h = 0,0,0,0 } Script Notice: WINDOWCONTROL = { nil } Script Notice: in OnValueChanged: Script Notice: false Script Notice: WINDOWINSTANCE = { class = charsheet_weaponlistitem, node = charsheet.id-00001.weaponlist.id-00001, x,y,w,h = 406,295,467,35 } Script Notice: STRINGCONTROL = { value = Bow, x,y,w,h = 0,10,110,15 } Script Notice: WINDOWCONTROL = { nil } Script Notice: in OnValueChanged: Script Notice: true Script Notice: WINDOWINSTANCE = { class = charsheet_weaponlistitem, node = charsheet.id-00001.weaponlist.id-00001, x,y,w,h = 406,295,467,35 } Script Notice: STRINGCONTROL = { value = Bow, x,y,w,h = 0,10,110,15 } Script Notice: WINDOWCONTROL = { nil }
EDIT: Looks like the nil value is a red-herring. Tried comparing to the common skills (which work) and I get nil for the checkbox there too.Last edited by Valarian; October 3rd, 2011 at 19:43.
Using Ultimate license - that means anyone can play.
Valarian's Fantasy Grounds Rulesets
-
October 3rd, 2011, 20:01 #6
Is the problem that your stringfield's onInit() function is not recognizing checkbox's value and rather always returns false? If this is the case, I recall facing similar issue and the problem was that checkbox is custom made, with own onInit function that actually initializes and binds it to datasource. Stringfield and stringcontrol seemed to behave differently when invoking onInit, like they would be called in different stages and that messed up the whole thing. Could you try out invoking checkboxes onInit at stringfield's onInit function?
"Alright, you primitive screwheads, listen up: THIS... is my BOOMSTICK!" -- Ash Williams, Army of Darkness
Post your SavageWorlds ruleset feature requests and issue reports here!
-
October 3rd, 2011, 20:18 #7
I've now got it working with the correct Debug output. Possibly to do with initialisation order. Still no underlines though.
Now have, in the checkbox script area:
Code:function onValueChanged() window.name.setUnderline(getState()) print("in OnValueChanged:") Debug.console(window) Debug.console(window.name) Debug.console(getState()) end function onInit() super.onInit() window.name.setUnderline(getState()) print("in OnInit: ") Debug.console(window) Debug.console(window.name) Debug.console(getState()) end
Code:Script Notice: in OnInit: Script Notice: WINDOWINSTANCE = { class = charsheet_weaponlistitem, node = charsheet.id-00001.weaponlist.id-00001, x,y,w,h = 0,0,0,0 } Script Notice: STRINGCONTROL = { value = Bow, x,y,w,h = 0,0,0,0 } Script Notice: bTRUE Script Notice: in OnInit: Script Notice: WINDOWINSTANCE = { class = charsheet_weaponlistitem, node = charsheet.id-00001.weaponlist.id-00002, x,y,w,h = 0,0,0,0 } Script Notice: STRINGCONTROL = { value = Short Sword, x,y,w,h = 0,0,0,0 } Script Notice: bFALSE Script Notice: in OnInit: Script Notice: WINDOWINSTANCE = { class = charsheet_weaponlistitem, node = charsheet.id-00001.weaponlist.id-00003, x,y,w,h = 0,0,0,0 } Script Notice: STRINGCONTROL = { value = Dagger, x,y,w,h = 0,0,0,0 } Script Notice: bFALSE Script Notice: in OnValueChanged: Script Notice: WINDOWINSTANCE = { class = charsheet_weaponlistitem, node = charsheet.id-00001.weaponlist.id-00001, x,y,w,h = 406,295,467,35 } Script Notice: STRINGCONTROL = { value = Bow, x,y,w,h = 0,10,110,15 } Script Notice: bFALSE Script Notice: in OnValueChanged: Script Notice: WINDOWINSTANCE = { class = charsheet_weaponlistitem, node = charsheet.id-00001.weaponlist.id-00001, x,y,w,h = 406,295,467,35 } Script Notice: STRINGCONTROL = { value = Bow, x,y,w,h = 0,10,110,15 } Script Notice: bTRUE
Last edited by Valarian; October 3rd, 2011 at 20:21.
Using Ultimate license - that means anyone can play.
Valarian's Fantasy Grounds Rulesets
-
October 5th, 2011, 18:43 #8
Still haven't got the underline to work properly, even though the Debug output looks correct.
I've tried putting a setUnderline script in the stringfield, to call the same method in the superclass. This doesn't seem to get called at all.
Code:function setUnderline(state) super.setUnderline(state) print("in setUnderline") Debug.console(state) end
Code:function onInit() print("in OnInit for name") setUnderline(true) end
Using Ultimate license - that means anyone can play.
Valarian's Fantasy Grounds Rulesets
-
October 5th, 2011, 23:39 #9
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,613
On the skills page in the 3.5E and 4E ruleset character sheets, the rulesets use a textline frame to denote underlining. Then the frame is set or cleared depending on whether the skill name is editable. (i.e. custom)
Check out charsheet/scripts/charsheet_skilllistitem.lua in the 3.5E ruleset.
I'll add a note to my to do list to check out setUnderline.
Thanks,
JPG
-
October 6th, 2011, 04:47 #10
Thanks, it's looking at the moment as if setUnderline is working only for static text stringcontrols. The setFrame won't work for me as there's no way to turn it off again.
The only way I can think of at the moment is a secondary invisible stringcontrol which has a frame and takes its value from the stringfield. Then display the stringcontrol instead of the stringfield if the favoured checkbox is ticked.Using Ultimate license - that means anyone can play.
Valarian's Fantasy Grounds Rulesets
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks