-
-
Notifications
You must be signed in to change notification settings - Fork 21.8k
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
Duplicating node by Ctrl+D duplicates code #38922
Comments
I think #37839 should fix that too. It's based on the current master(ignore the branch name) maybe it should be cherry-picked for 3.2 @akien-mga ? |
I found that #37839 does not fully fix this issue. |
I found another issue that Ctrl+A is handled on both script editor and scene tree dock.
I guess it needs to find why this regression happens in the first place. |
I am experiencing this in 3.2.1 stable as well btw. Something I noticed but never created an issue for, so thanks! 😂 |
I could not replicate that on my machine(Windows 10) but what is strange is that it looks exacly like in your example: the scene dock has focus (white highlighted border), a node is selected but only the code line is duplicated if I press Ctrl+D. Edit: Edit2: |
I have the same results as @volzhs, #37839 does not resolve the issue for me. I think the issue lies deeper than that PR. I have had a look into it further and noticed a few things. The "duplicate" bug and "select all/new node" bug actually have 2 different causes (but in the end are related to the same underlying issue): The sequence of events/method calls:
Solution: handle the button event first, so the event doesn't keep propagating. Control focus seems to have nothing to do with this problem. Duplicate Node (Control + D)
So, in this case, yes, #37839 does fix this as the `_input() call will stop running since the text editor does not have focus. But the same issue as before arises, because there are 2 paths to get to the code to clone a line.
So yes, while the PR does fix 1., 2. still persists the issue. |
@EricEzaM said
@MrRevington said
so. maybe it's not regression, but not solved for a long time I think. |
So basically shortcuts are a bit cooked, because it doesn't matter where they are initiated from - they are checked in every available menu that has shortcuts. This means that multiple shortcuts with the same key combo are a no-go. For example, try this:
This happens because the text editor receives the event first and accepts it. Now, go to your editor settings and change "Script Editor" -> "Undo" to something thats not control + Z, and try the same thing again. Lo and behold, the undo now works for the scene tree. This behaviour is visible almost anywhere where there are duplicate shortcut keys. The thing is that shortcuts can be initiated from several different input handling methods:
So shortcut clashes exist where the shortcuts are handled at the same "level". So this just adds exceptions to the issue, and cause further complexity. |
Yep, just as I had thought... In the code below, every node which implements godot/scene/main/scene_tree.cpp Lines 857 to 885 in 4645097
Not really sure how one would go about resolving this... seems like an issue that would require core changes to how shortcuts are checked and input is handled. We could potentially make it so that shortcuts only work where the user has focus... But this would mean some duplication of shortcuts or "fallback" system. For example, if you are focused in the Canvas Item Editor (or Spatial Editor), then pressing Control + D will still duplicate a the node, however this shortcut goes through the scene tree dock, not the item editor itself. So you would need to make duplicates of shortcuts, or have some sort of fallback system where the item editor will check the scene tree dock after it checks itself for shortcut matches. Just spitballing here, but you get the idea. @akien-mga any thoughts? Should a new issue be started dealing with the shortcut issue I have found here? |
Duplicate of #36205. |
Fixes godotengine#38922, #337807, godotengine#37054 and potentially others. This fix adds a check in viewport.cpp which checks that the focused node and none of its parents can handle the input, before propagating the input to all editor nodes which implement _unhandled_key_input. Also, a few accept_events() were added where needed to stop multiple shortcuts from running at once. See godotengine#38922 for more comments. Replaces/builds upon godotengine#37839 and godotengine#37068.
Godot version:
3.2.2 beta 2 8cf450c
OS/device including version:
Linux mint 19.3
Issue description:
Duplicating node by Ctrl+D duplicates code of current line, not duplicating node.
Steps to reproduce:
Minimal reproduction project:
The text was updated successfully, but these errors were encountered: