Open DestyNova opened 1 month ago
Hello! Sure there are can be some misunderstanding, so we can help each other to understand it better ;)
For input component you should pass the key ids that trigger this hotkey, for example
self.druid:new_hotkey("key_g", ...)
-- or
self.druid:new_hotkey({ "key_lshift", "key_a" }, ...)
The list of "modificator" key_ids are listed in the default style.lua
and it equals to
modificator keys is something that tracked to be pressed before other keys in the hotkey list
M["hotkey"] = { -- Add key ids to mark it as modificator keys MODIFICATORS = { "key_lshift", "key_rshift", "key_lctrl", "key_rctrl", "key_lalt", "key_ralt" } }
So "Druid utilize default bindings" means this default modificator key ids.
If you are using this all.input_bindings
, all things should work from the box without any modification.
Also, if you don't need any modificators and want to add callback just for one key, you also can use next thing:
local button = self.druid:new_button("button_node", ...)
button:set_key_trigger("key_g")
About live example: In browser some of hotkeys can be hooked by the browser itself. In Druid example my ctrl + g
is working, by cmd + g
is shows the text search as you said. Which system do you use? (Windows/Linux/MacOS)
Thanks for that quick response! I did get it working earlier with a single hotkey, but had to add that hotkey to my input bindings. I think my misunderstanding is related to what you said here:
If you are using this
all.input_binding
I didn't even think about whether I was using it or not, and just assumed Druid magically uses it once the dependency is installed. Now I see there are two ways to use hotkeys:
/builtin/...
in the game config file, or/input/game.input_binding
So I wrongly assumed option 1 was sort of implicitly done when using Druid, but it's not. Probably anyone with more experience using Defold would not make that mistake, so we can probably close this đŸ˜…
[Edit] Oh and I'm using Linux. I tried both super-g and ctrl-g in the example but neither worked in the HTML5 version. Might be good to change it to another combo (maybe ctrl-e? there's not many free key combos left!) or just use a non-modifier hotkey.
Good catch for the example issue, will update it!
But I didn't get the which exactly thing should be better explained. In short current workflow I can describe next:
Input bindings is just a map with key_id
with action_id
for your game. If you wish to use custom key_id (for example "shift" instead of "key_lshift"), you make a your input bindings with custom key_ids and update the Druid style. If you don't use modifiers, you just pass the your game "key_id" to the Hotkey constructor
So probably the advantage for this will be to add something about how input bindings works in Defold? wdyt?
But I didn't get the which exactly thing should be better explained. In short current workflow I can describe next:
Input bindings is just a map with
key_id
withaction_id
for your game. If you wish to use custom key_id (for example "shift" instead of "key_lshift"), you make a your input bindings with custom key_ids and update the Druid style. If you don't use modifiers, you just pass the your game "key_id" to the Hotkey constructor
That workflow makes sense now -- I think the remaining question mark is that the above workflow still requires you to either declare the "non-custom" bindings, e.g. key_a
or "use" the all.input_binding
file, a step I thought happened automagically.
When I read this sentence from the README:
Druid utilizes the /builtins/input/all.input_binding input bindings
what my brain actually told me was:
You can make a blank project, install the Druid dependency, then immediately use a hotkey with "standard" bindings like
key_a
, without touching any settings or editing the input bindings file
So yeah I think adding a little "basic Defold" note there could help, e.g. something like this in the README (and Hotkey API page)? Assuming I finally understand things :smile:
- Druid utilizes the /builtins/input/all.input_binding input bindings. For custom input
- bindings, refer to the Input Binding section in the [Advanced Setup](https://github.com/Insality/druid/blob/master/docs_md/advanced-setup.md#input-bindings).
+ Druid utilizes the /builtins/input/all.input_binding input bindings. Either use this
+ file for your project by setting the `Game binding` field in the `game.project` input
+ section to `/builtins/input/all.input_binding`, or add the specific bindings you need
+ to your game's input binding file. For custom input bindings, refer to the Input Binding
+ section in the [Advanced Setup](https://github.com/Insality/druid/blob/master/docs_md/advanced-setup.md#input-bindings).
I ran into some confusion with
hotkey
after reading this part of the README:I took the reference to "all.input_binding" to mean that hotkeys would work with any key action defined there, but that's not how it is. Instead, any hotkey you want to use must have custom bindings defined in
/input/game.input_binding
. Perhaps we could add something to that effect (although I may be the first person on the planet who has misinterpreted the docs in this way).Incidentally when I clicked the hotkey example on the Druid site, it uses ctrl-G which doesn't seem to work in either Firefox or Chrome for me; it triggers the browser text search feature instead.
[edit] I know the second half of that quote literally mentions "custom input bindings", but I wasn't sure what that meant, thinking maybe it meant gamepad inputs or something. Maybe it's clear enough and I just haven't had enough sleep!