set_dialog_value for tooltips

Discussion of Lua and LuaWML support, development, and ideas.

Moderator: Forum Moderators

Post Reply
User avatar
doofus-01
Art Director
Posts: 4122
Joined: January 6th, 2008, 9:27 pm
Location: USA

set_dialog_value for tooltips

Post by doofus-01 »

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?
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
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: set_dialog_value for tooltips

Post by gfgtdf »

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
Iirc i just create a the dialog wml (the T.grid content) dynamicaly and add tooltip= fields to those elements.
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"?
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: 2. Is there some similar way to set the tooltip string?
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.
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.
User avatar
doofus-01
Art Director
Posts: 4122
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: set_dialog_value for tooltips

Post by doofus-01 »

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?
Actually, there doesn't seem to be any such widget, that's just some buggy autodocumentation. So never mind that.
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.
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.

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}
...
but if I try using table.insert(equipment_grid_list_data, ({"row", {equip_data}})) or something similar, I can't seem to make a valid WML table. I have a feeling this is a really stupid mistake, I'm trying (I think) to make a list of {"row", {<row_content_such_as_T.column>}} items. Is that not correct?
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
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: set_dialog_value for tooltips

Post by gfgtdf »

in lua wml tbles are encoded in like

Code: Select all

{"tagname", {
  a=6
  {"subtagname", {

  }},
  {"subtagname", {

  }}
}}

so you so there are 'tag' table which represent tag

Code: Select all

  {"subtagname", {

  }},
and 'content' tabkles which represent a tags content for example

Code: Select all

{
  a=6
  {"subtagname", {

  }},
  {"subtagname", {

  }}
}

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. 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 table
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.
Post Reply