[solved] two [grid] tags
Moderator: Forum Moderators
- ZombieKnight
- Posts: 283
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: two [grid] tags
Thanks, I couldn't find the .on_modified. I'll report back after lunch...
Any idea how to resize/make the text_box transparent?
I haven't found any mainline uses of that.
Any idea how to resize/make the text_box transparent?
I haven't found any mainline uses of that.
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills
- ZombieKnight
- Posts: 283
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: two [grid] tags
Jup
works
...
Any idea why:
'dialog.test_text.on_left_click = function() dialog:close() end'
Doesn't work and break the white_haired_uncle's code?
Code: Select all
dialog.test_text.on_modified=function()
if dialog.test_text.text == " " then dialog:close() end
dialog.test_text.text =""
end
...
Any idea why:
'dialog.test_text.on_left_click = function() dialog:close() end'
Doesn't work and break the white_haired_uncle's code?
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills
- ZombieKnight
- Posts: 283
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: two [grid] tags
For the resize and making it invisible...
What is that?
https://devdocs.wesnoth.org/classgui2_1 ... ce9225c0ab
What is that?
https://devdocs.wesnoth.org/classgui2_1 ... ce9225c0ab
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills
- Celtic_Minstrel
- Developer
- Posts: 2290
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: two [grid] tags
Yes – either that or "gui.widget.focus(dialog.test_text)".ZombieKnight wrote: ↑April 27th, 2024, 7:42 am Thanks!
Oh dumb me, this works "dialog.test_text:focus()"
Just to clarify, that doesn't hide it. It deletes it. There's no difference though as long as you don't want it back later.ZombieKnight wrote: ↑April 27th, 2024, 7:43 am I useTo hide the label background...Any idea how to hide text_box background?Code: Select all
dialog:set_canvas(1, { } )
- ZombieKnight
- Posts: 283
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: two [grid] tags
Oh, good to know!
How to delete any image of text_box?
How to delete any image of text_box?
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills
-
- Posts: 1310
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: two [grid] tags
Here is an invisible text box that will capture keyboard input:
When I add the on_left_click I can close the gui with a left click, but it also closes if I type more than one key. If all you're really trying to do is make it really easy to close the gui (which you also can't otherwise interact with), I think that would work for you. But I think it might be a bug, as I don't think pressing the letter 'o' (for example) should be handled by on_left_click.
I should test this to see if it is something odd about on_left_click, or (more likely?) an issue with having both callbacks active.
Code: Select all
local T = wml.tag
local chat = wesnoth.interface.add_chat_message
local sf = string.format
function wesnoth.wml_actions.stacked_widget_gui()
local dialogDefinition = {
wml.tag.tooltip { id = "tooltip_large" },
wml.tag.helptip { id = "helptip_large" },
wml.tag.grid { wml.tag.row { wml.tag.column {
wml.tag.stacked_widget {
id = "stacker",
definition = "default",
T.layer {
T.row { T.column { T.label { id="my_label1",label = "Hello world" } } }
},
T.layer {
T.row { T.column { T.text_box { id="my_tb" } } }
}
}
} } },
}
local function preshow(dialog)
-- wesnoth.print_attributes(dialog.stacker)
-- gui.show_lua_console()
--
dialog.stacker.my_label1.visible = true
dialog.stacker.my_tb.visible = false
dialog.my_tb:focus()
dialog.my_tb.on_modified = function()
chat(sf("Text box contains %s",tostring(dialog.my_tb.text)))
-- dialog.my_tb.on_left_click = function()
-- dialog:close()
-- end
--dialog.stacker.visible = false
end
end
gui.show_dialog(dialogDefinition,preshow)
end
I should test this to see if it is something odd about on_left_click, or (more likely?) an issue with having both callbacks active.
Last edited by white_haired_uncle on April 27th, 2024, 1:54 pm, edited 1 time in total.
Speak softly, and carry Doombringer.
- ZombieKnight
- Posts: 283
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: two [grid] tags
So I just need to set it to visible = false.
Thanks!
Aaand any idea why my on_left_click isn't working?
Thanks!
Aaand any idea why my on_left_click isn't working?
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills
-
- Posts: 1310
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: two [grid] tags
I just edited my previous message, adding in on_left_click
Well, I was wrong. I added click_dismiss = true at the top level (next to tooltip/helptip), and that was what was actually causing the left click to close the gui.
It looks like if you set on_left_click on a text_box, it will be called on keyboard input, but NOT from a mouse click (even with no on_modified callback). It I'm right, that's just weird.
Okay, try this. You can use either left click or space bar to close the gui, and the input is invisible:
Well, I was wrong. I added click_dismiss = true at the top level (next to tooltip/helptip), and that was what was actually causing the left click to close the gui.
It looks like if you set on_left_click on a text_box, it will be called on keyboard input, but NOT from a mouse click (even with no on_modified callback). It I'm right, that's just weird.
Okay, try this. You can use either left click or space bar to close the gui, and the input is invisible:
Code: Select all
function wesnoth.wml_actions.stacked_widget_gui()
local dialogDefinition = {
wml.tag.tooltip { id = "tooltip_large" },
wml.tag.helptip { id = "helptip_large" },
click_dismiss = true,
wml.tag.grid { wml.tag.row { wml.tag.column {
wml.tag.stacked_widget {
id = "stacker",
definition = "default",
T.layer {
T.row { T.column { T.label { id="my_label1",label = "Hello world" } } }
},
T.layer {
T.row { T.column { T.text_box { id="my_tb" } } }
}
}
} } },
}
local function preshow(dialog)
dialog.stacker.my_label1.visible = true
dialog.stacker.my_tb.visible = false
dialog.my_tb:focus()
dialog.my_tb.on_modified = function()
if dialog.my_tb.text == " " then dialog:close() end
chat(sf("Text box contains %s",tostring(dialog.my_tb.text)))
end
end
gui.show_dialog(dialogDefinition,preshow)
end
Last edited by white_haired_uncle on April 27th, 2024, 2:05 pm, edited 1 time in total.
Speak softly, and carry Doombringer.
Re: two [grid] tags
That does not match what previously described use case was. You code that after something has been entered, start listening for mouse event. But mouse event callback just does not work anyways https://github.com/wesnoth/wesnoth/issues/8815
- ZombieKnight
- Posts: 283
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: two [grid] tags
I had no idea I could put click_dismiss there.
...
Thanks!
Now I have a working, fully message-like-closing custom_message([narration])
^^ <3
...
Thanks!
Now I have a working, fully message-like-closing custom_message([narration])
^^ <3
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills
Re: two [grid] tags
Your latest version does not need callbacks at all. Can be simplified to
Code: Select all
# lua wesnoth.require("wml-utils").handle_event_commands(wml.load("~add-ons/EventLoader/action.cfg"))
[lua]
code=<<
local T = wml.tag
local chat = wesnoth.interface.add_chat_message
local sf = string.format
function wesnoth.wml_actions.stacked_widget_gui()
local dialogDefinition = {
wml.tag.tooltip { id = "tooltip_large" },
wml.tag.helptip { id = "helptip_large" },
click_dismiss = true,
wml.tag.grid { wml.tag.row { wml.tag.column {
wml.tag.stacked_widget {
id = "stacker",
definition = "default",
T.layer {
T.row { T.column { T.label { id="my_label1",label = "Hello world" } } }
}
}
} } },
}
local function preshow(dialog)
end
gui.show_dialog(dialogDefinition,preshow)
end
wesnoth.wml_actions.stacked_widget_gui()
>>
[/lua]
- ZombieKnight
- Posts: 283
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: [solved] two [grid] tags
Wait...
All the time all I needed was click_dismiss???
All the time all I needed was click_dismiss???
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills
- ZombieKnight
- Posts: 283
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: [solved] two [grid] tags
Got some usefull xp on the way...
But still...
Good to know, thanks!
But still...
Good to know, thanks!
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills
-
- Posts: 1310
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: [solved] two [grid] tags
"~add-ons/EventLoader/action.cfg" ?
Speak softly, and carry Doombringer.
- ZombieKnight
- Posts: 283
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: [solved] two [grid] tags
That's what?
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills