[unsolvable] Can add-on register key pressed while gui.show_dialog is active? e.g. >a<, >space< ...

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

Moderator: Forum Moderators

Post Reply
User avatar
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

[unsolvable] Can add-on register key pressed while gui.show_dialog is active? e.g. >a<, >space< ...

Post by ZombieKnight »

I've asked this question already... but got no answer.
Is there way for add-on to register when key is pressed on keyboard while gui.show_dialog is active?
I'd like to dialog:close() when >space< is pressed, just like in [message]
Last edited by ZombieKnight on April 20th, 2024, 5:52 am, edited 2 times in total.
I had saurian in profile before, but I've merged my discord profile with forum one...
User avatar
Celtic_Minstrel
Developer
Posts: 2241
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Can add-on register key pressed? e.g. >a<, >space< ...

Post by Celtic_Minstrel »

Try [set_menu_item].

Of course, that'll only work on the map, not in a dialog… probably.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: Can add-on register key pressed? e.g. >a<, >space< ...

Post by ZombieKnight »

... Sry for delay
[default_hotkey]: contains a hotkey WML to specify what hotkey to assign to this, if the user has no hotkey assigned to this yet. (Unlike the rest of a menu item definition, modifying this tag has no effect on the game; it is only effective when initially defining a menu item.) Hotkey WML matches the format in the preferences file and contains the following keys:

key: a string that contains the key to assign to this.
alt, shift, cmd(apple only), ctrl: boolean values.
repeat_on_hold (Version 1.13.12 and later only): if yes (default no), holding the hotkey will repeat the action continuously, unless it blocks input with something like [message]. Due to a bug, versions older than 1.13.12 always repeat the action, with no way to disable it.
"unless it blocks input with something like [message]" seems like so
I had saurian in profile before, but I've merged my discord profile with forum one...
User avatar
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: Can add-on register key pressed while gui.show_dialog is active? e.g. >a<, >space< ...

Post by ZombieKnight »

Sorry, my question was badly written, my bad.
I've edited it now...
...
Is there way for add-on to register when key is pressed on keyboard while gui.show_dialog is active?
I'd like to dialog:close() when >space< is pressed, just like in [message]
I had saurian in profile before, but I've merged my discord profile with forum one...
User avatar
Celtic_Minstrel
Developer
Posts: 2241
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Can add-on register key pressed while gui.show_dialog is active? e.g. >a<, >space< ...

Post by Celtic_Minstrel »

No.

The GUI2 system provides at least two different ways to do it, but they're not exposed in the Lua API.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
white_haired_uncle
Posts: 1226
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: Can add-on register key pressed while gui.show_dialog is active? e.g. >a<, >space< ...

Post by white_haired_uncle »

A text_box, focus(), and on_modified?

Sorry, I'll be quiet now.
Speak softly, and carry Doombringer.
User avatar
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: Can add-on register key pressed while gui.show_dialog is active? e.g. >a<, >space< ...

Post by ZombieKnight »

white_haired_uncle wrote: April 17th, 2024, 3:04 am A text_box, focus(), and on_modified?
Can I display two custom dialogs on top of each other?
First: my message, on top invisible text box?
I had saurian in profile before, but I've merged my discord profile with forum one...
User avatar
Celtic_Minstrel
Developer
Posts: 2241
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Can add-on register key pressed while gui.show_dialog is active? e.g. >a<, >space< ...

Post by Celtic_Minstrel »

You can display dialogs on top of each other, but only the one on the top can be interacted with, even if it's completely transparent.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: Can add-on register key pressed while gui.show_dialog is active? e.g. >a<, >space< ...

Post by ZombieKnight »

Sounds like that solves my problem, this workaround,
How to make an invisible text input dialog all over the screen?
I had saurian in profile before, but I've merged my discord profile with forum one...
white_haired_uncle
Posts: 1226
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: Can add-on register key pressed while gui.show_dialog is active? e.g. >a<, >space< ...

Post by white_haired_uncle »

I don't know if you could make the text_box invisible, I've only found doing that for a dialog (background). I was thinking maybe, MAYBE, you could hide it by putting it in a panel and then drawing something over it so you couldn't see the box, use focus to force it to get attention, and on_modified to catch your keyboard input and potentially erase any other text that was sent to the box.

Please understand, I'm just making stuff up. There's about zero chance this would work. Not zero perhaps, but close.
Speak softly, and carry Doombringer.
User avatar
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: Can add-on register key pressed while gui.show_dialog is active? e.g. >a<, >space< ...

Post by ZombieKnight »

Ok, I'll try.
It would be weird if you had to close the message-like dialog using esc/Enter.
I had saurian in profile before, but I've merged my discord profile with forum one...
Post Reply