-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix some keys triggering their actions twice in GridMap #81531
Conversation
So this is a pretty big regression, I really hope we can find a solution to this in time for 2.2! Regarding the implementation: It is impossible for the gridmap plugin to know which of its keybindings are used by other plugins so the solution I found is everytime a key is pressed in the grimap, if it's mapped to a GridMap action, trigger this action from I'm not familiar enough with the event propagation in Godot but it seems to me that both calling I'm not sure why, for instance, accepting the event in the menu option handler does NOT do the same thing: void GridMapEditor::_menu_option(int p_option) {
// this does not work
options->accept_event();
...
} This implementation does have a side effect though.
Without the code from #79529, while having the editor focused, both actions would be triggered, which is very annoying. With the code from #79529, while having the editor focused, the gridmap action will always take precedence. I think this approach, while not perfect is a massive improvement from the previous state but I'd really like some maintainer's opinion about the matter! It also feels a bit like a hack if I'm being totally honest... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the main issue here is that 2D and 3D editors handle events differently. 2D editor will accept events automatically:
godot/editor/plugins/canvas_item_editor_plugin.cpp
Lines 2594 to 2596 in 3ed4497
if (accepted) { | |
accept_event(); | |
} |
While 3D doesn't:
godot/editor/plugins/node_3d_editor_plugin.cpp
Lines 1614 to 1616 in 3ed4497
if (discard == EditorPlugin::AFTER_GUI_INPUT_STOP) { | |
return; | |
} |
I wasn't able to find an example of using
accept_event()
event in another plugin, but seems like only GridMap is using keyboard shortcuts (at least the way you implemented it).
I do think the current behavior is correct, as users expect that shortcuts work in the context they are currently using (as proven by countless issues about deleting nodes while editing some unrelated thing). TileMap also uses similar code since #80317
Given the aforementioned inconsistency and lack of keyboard examples in other plugins, I think this fix is fine.
Oh woah. This is a bit unexpected. I'm guessing changing it would break everyone's workflow at this point.
However, the real problem here is that |
I think the event first goes to the editor and then to the menu; in opposite order it would be fine, because the menu accepts events properly. |
Thanks! |
This is a bug introduced by #79529.
Some keys (not all) trigger the associated action twice: one is triggered by the
forward_spatial_input_event
method as intended in the PR and another time from the menu event handler (not intended, we were supposed to prevent further inputs).The original code contained the
accept_event()
statement but it was removed after the code review.Apologies for not testing this thoroughly... 😞
@KoBeWi Can I have your input on this, I'm not sure if it's the right way but it does fix the bug.