set_dialog_value for tooltips
Moderator: Forum Moderators
set_dialog_value for tooltips
Hi,
I was wondering if there was a way to easily set the tooltip of a widget, similar to wesnoth.set_dialog_value. In Scenario with Robots add-on, it looks like elements with tooltips can be constructed in a way that sort of mimics this, but it isn't very intuitive and even if I figure out what's going on there, I won't remember next time I look at it. I have two questions:
1. Is wesnoth.set_dialog_value really setting the widget "label"? Or is there some other thing called a "value"?
2. Is there some similar way to set the tooltip string?
On a similar note, there is a apparently a widget called a "Tooltip": https://wiki.wesnoth.org/GUIToolkitWML , but the links are dead (not sure how much they would help anyway) and it's not clear to me how that would work. Do you need to stack it with something visible?
I was wondering if there was a way to easily set the tooltip of a widget, similar to wesnoth.set_dialog_value. In Scenario with Robots add-on, it looks like elements with tooltips can be constructed in a way that sort of mimics this, but it isn't very intuitive and even if I figure out what's going on there, I won't remember next time I look at it. I have two questions:
1. Is wesnoth.set_dialog_value really setting the widget "label"? Or is there some other thing called a "value"?
2. Is there some similar way to set the tooltip string?
On a similar note, there is a apparently a widget called a "Tooltip": https://wiki.wesnoth.org/GUIToolkitWML , but the links are dead (not sure how much they would help anyway) and it's not clear to me how that would work. Do you need to stack it with something visible?
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
Re: set_dialog_value for tooltips
Iirc i just create a the dialog wml (the T.grid content) dynamicaly and add tooltip= fields to those elements.doofus-01 wrote:Hi,
I was wondering if there was a way to easily set the tooltip of a widget, similar to wesnoth.set_dialog_value. In Scenario with Robots add-on, it looks like elements with tooltips can be constructed in a way that sort of mimics this, but it isn't very intuitive and even if I figure out what's going on there
What wesnoth.set_dialog_value does depends on the widget, for most widgets it will just set 'label', but for examepl for listboxes it sill set shich elemnt is currently selected.doofus-01 wrote:
I won't remember next time I look at it. I have two questions:
1. Is wesnoth.set_dialog_value really setting the widget "label"? Or is there some other thing called a "value"?
Afaik not, i think in lua you can only set the toolip via the tooltip= field in the dialogs wml, feel free to file a featurerequest for adding a method to set tooltips.doofus-01 wrote: 2. Is there some similar way to set the tooltip string?
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
Re: set_dialog_value for tooltips
Actually, there doesn't seem to be any such widget, that's just some buggy autodocumentation. So never mind that.doofus-01 wrote:On a similar note, there is a apparently a widget called a "Tooltip": https://wiki.wesnoth.org/GUIToolkitWML , but the links are dead (not sure how much they would help anyway) and it's not clear to me how that would work. Do you need to stack it with something visible?
I can almost do the tooltip thing with writing [list_data], but I don't seem to be able to get more than one item in the listbox.gfgtdf wrote:Afaik not, i think in lua you can only set the toolip via the tooltip= field in the dialogs wml, feel free to file a featurerequest for adding a method to set tooltips.
This works for putting the last [gear] array data from the unit's variables in the dialog (the equipped items in the "status dialog")
Code: Select all
function equipment_grid_data(equ_icon, equ_label, equ_tooltip)
wesnoth.message(equ_icon)
return T.column{
T.widget{id = "the_gearlist_icon", label = equ_icon, tooltip = equ_tooltip},
T.widget{id = "the_gearlist_icon_name", label = equ_label, tooltip = equ_tooltip}
}
end
...
local unit_cfg = wesnoth.get_unit(event_context.x1,event_context.y1).__cfg
local u_gear = helper.get_child(unit_cfg, "variables")
for gear in helper.child_range(u_gear, "gear") do
local equip_data = equipment_grid_data(string.format("%s~SCALE(60,60)", gear.image), string.format("<span size='xx-small'>%s</span>", gear.name), gear.text)
equipment_grid_list_data = {"row", {equip_data}}
end
...
T.list_data{equipment_grid_list_data}
...
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
Re: set_dialog_value for tooltips
in lua wml tbles are encoded in like
so you so there are 'tag' table which represent tag
and 'content' tabkles which represent a tags content for example
when you create wml tag tables like equipment_grid_list_data you alwa<ys have to knowof whihc of these 2 tyes your variables are.
Code: Select all
{"tagname", {
a=6
{"subtagname", {
}},
{"subtagname", {
}}
}}
Code: Select all
{"subtagname", {
}},
Code: Select all
{
a=6
{"subtagname", {
}},
{"subtagname", {
}}
}
T.list_data{equipment_grid_list_data}
only works if equipment_grid_list_data is a 'tag table' but table.insert(equipment_grid_list_data, ({"row", {equip_data}}))
assumes that equipment_grid_list_data is a content tableScenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.