Key modifiers in on_gui_click
Key modifiers in on_gui_click
It would be great if we could know which mouse button and key modifier were pressed in on_gui_click:
example
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: Key modifiers in on_gui_click
+1
Only tweak I'd make is for consistency with way mods define keyboard shortcuts: capitalise first letter, eg. "Shift" instead of "shift"
Only tweak I'd make is for consistency with way mods define keyboard shortcuts: capitalise first letter, eg. "Shift" instead of "shift"
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Re: Key modifiers in on_gui_click
"SHIFT" - as when defining hotkeys. =)aubergine18 wrote:+1
Only tweak I'd make is for consistency with way mods define keyboard shortcuts: capitalise first letter, eg. "Shift" instead of "shift"
Code: Select all
data:extend({
{
type = "custom-input",
name = "my-mod-hot-key",
key_sequence = "SHIFT + Y",
consuming = "script-only"
}
})
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: Key modifiers in on_gui_click
yes, you are correct
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: Key modifiers in on_gui_click
The ability to scan the keyboard in scripts to determine if a key is pressed or not would definitely be useful (even outside of on_gui_click), I can't remember what it was right now, but I remember I wanted to program something in where if you did something while holding a key, it would do it differently (I think it was a settings copy script if you placed an entity while holding a key)
Re: Key modifiers in on_gui_click
What does "consuming" means? I can't find hotkey definitions anywhere in the lua-api doc.apriori wrote:"SHIFT" - as when defining hotkeys. =)aubergine18 wrote:+1
Only tweak I'd make is for consistency with way mods define keyboard shortcuts: capitalise first letter, eg. "Shift" instead of "shift"Code: Select all
data:extend({ { type = "custom-input", name = "my-mod-hot-key", key_sequence = "SHIFT + Y", consuming = "script-only" } })
Re: Key modifiers in on_gui_click
Instead of having key_modifier be a single value make it a dictionary to support combinations
Code: Select all
if(event.key_modifiers.SHIFT and event.key_modifiers.ALT) then
...
-
- Filter Inserter
- Posts: 841
- Joined: Mon Sep 14, 2015 7:40 am
- Contact:
Re: Key modifiers in on_gui_click
See: http://pastebin.com/raw/k44Ed5Gzkiba wrote:What does "consuming" means? I can't find hotkey definitions anywhere in the lua-api doc.
Re: Key modifiers in on_gui_click
I second this. And I think mknejp's solution works better.
Re: Key modifiers in on_gui_click
The current system for detecting input actions and firing events in Factorio doesn't preserve data like this.
When the button is clicked it sends a 4 byte event "button clicked" - none of the data about which button or what keys are held down is stored in that event. It works this way because those events are saved in replays and are sent over the network for Multiplayer games. If the entire keyboard state was stored in those events it would be crazy.
Because of that, this isn't likely to ever happen.
When the button is clicked it sends a 4 byte event "button clicked" - none of the data about which button or what keys are held down is stored in that event. It works this way because those events are saved in replays and are sent over the network for Multiplayer games. If the entire keyboard state was stored in those events it would be crazy.
Because of that, this isn't likely to ever happen.
If you want to get ahold of me I'm almost always on Discord.
Re: Key modifiers in on_gui_click
Would just adding another byte (really just 3 bits) to the event to keep track of modifier keys like SHIFT, CONTROL, ALT be too much?
Perhaps 1 more bit to say it was a right click otherwise assume left click (even for a middle click or mice with 4+ buttons on them).
Perhaps 1 more bit to say it was a right click otherwise assume left click (even for a middle click or mice with 4+ buttons on them).
Re: Key modifiers in on_gui_click
If *all* you want is those modifier keys then sure I guess it wouldn't be out of the question to add those.credomane wrote:Would just adding another byte (really just 3 bits) to the event to keep track of modifier keys like SHIFT, CONTROL, ALT be too much?
Perhaps 1 more bit to say it was a right click otherwise assume left click (even for a middle click or mice with 4+ buttons on them).
If you want to get ahold of me I'm almost always on Discord.
Re: Key modifiers in on_gui_click
It is certainly all I want. Knowing if any modifier keys were held on click and if the click was left or right click would be absolutely amazing.Rseding91 wrote:If *all* you want is those modifier keys then sure I guess it wouldn't be out of the question to add those.
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
The only thing I could see others wanting would be to know if the SHIFT, CONTROL, and ALT modifiers were the left or right side of the keyboard.
As for all other keys on a keyboard I dunno why anyone would want the letter "K" as a modifier for a left click on a button. That even looks weird typing it out like I did.
Re: Key modifiers in on_gui_click
You are already using modifiers and mouse buttons in GUIs: in grids of inventories. I vote for the same in custom GUIs. That's all.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: Key modifiers in on_gui_click
Well, I wanted somethng crazy like "L", but, I could work with the standard 3 key modifiers.
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: Key modifiers in on_gui_click
Just having standard key modifiers (Control, Shift, Alt) would suffice IMO. Addition of being able to determine if it was left or right mouse click would be icing on cake.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Re: Key modifiers in on_gui_click
Of-course Bob does. Should have known.bobingabout wrote:Well, I wanted somethng crazy like "L", but, I could work with the standard 3 key modifiers.
![Razz :P](./images/smilies/icon_razz.gif)