PDA

View Full Version : New V3 buttonfield (buttoncontrol)



bzjeurd
August 16th, 2013, 12:05
Hello,

Is it already possible to have some details informations (as we can found in the Ruleset Reference section) about the new buttonfield/buttoncontrol ?

I tried to add some text in and out the <state> tag but without any success.

I know the version 3 is still in alpha... but I will really appreciate some help about this request.

JC

Moon Wizard
August 17th, 2013, 06:45
There's actually a fair bit of information, and I need to organize it better for sharing.

Here is a rough overview.

All buttons can have a single "state" that can be customized using the "frame", "font", "text" and "icon" tags.

To define multiple states or customize states, you define one or more state tags that represent the visual state of the button when the button has each state value. The numeric values assigned to a buttoncontrol/buttonfield are a number data type, and are numbered from 0 for the first state tag defined, 1 for the second state tag defined, and so on. The state tag supports frame, frameoffset, icon, text, font, and offset tags.

Also, you can define "pressed" and "hover" tags to match the "state" tags to customize the "pressed" and "hover" states of each button number value.

Regards,
JPG

bzjeurd
August 19th, 2013, 13:06
Thank you for you answer moon_wizard.

I did some script test on the buttoncontrol, and the result is strange.
1 I tried to use the setText() function in the onInit() event function, but the text never appeared.
And I also tried to add a bitmapwidget to this control (don't ask why :)) inside the onInit() function of the control itself but even if the widget is created (I can display its property in the debug console) it is not displayed. If I do the same (addbitmapwidget) on other control at the onInit() level, it works fine...

bzjeurd
August 29th, 2013, 18:01
Hi,
I found another bug/limitation with the buttonfield control, as the state tags are not named (just a list of tags), when you try to merge your own control with a template built with the buttonfield control, the result of the join merging process is: only the last occurence of the <state> tag of the template is applied for all tags in your control button.
Is it a way to identify each <state> tags or a "name" attribute so we can merge template correctly?
Bz

Moon Wizard
September 1st, 2013, 07:04
It's one of the limitations of the merging process to make it easier in the more general cases.

Try adding the merge="add" attribute to each of the state tags to append all the states. Also, you can use a single merge="resetandadd" on the first instance to override any existing states.

Regards,
JPG

bzjeurd
December 31st, 2013, 12:32
Hooo! I finally tried with succes the merge="add" and it it worked fine... sorry I forgot the "add" merge rule for template.
Thanks for your help Moon_wizzard.
Bz

meathome
February 19th, 2014, 10:36
Hi, How can I set the states from script?

Trenloe
February 19th, 2014, 12:18
Hi, How can I set the states from script?
Are you looking to dynamically add/remove states via LUA or just change the text of an existing state?

I don't think you can specifically remove/add states at run time.

However, you could have a buttonfieldcontrol template with a lot of blank states and use the setStateText command at runtime to make a state "visible": http://www.fantasygrounds.com/refdoc/buttoncontrol.xcp#setStateText

Then, using the onButtonPress event http://www.fantasygrounds.com/refdoc/buttoncontrol.xcp#onButtonPress you could monitor the current state (via getValue) and recycle back to 0 (with setValue) if the button value was greater than the number of states you wanted to use (even though your template may have more, blank, states).

meathome
February 19th, 2014, 19:23
I did want to add and remove states via lua, but managed to work around it. Actually I did something a lot like what you suggested. thank you!