Skip to content
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

Cannot assign % as shortcut for Toggle Access as Unique Name #104594

Closed
ttencate opened this issue Mar 25, 2025 · 5 comments
Closed

Cannot assign % as shortcut for Toggle Access as Unique Name #104594

ttencate opened this issue Mar 25, 2025 · 5 comments

Comments

@ttencate
Copy link
Contributor

ttencate commented Mar 25, 2025

Tested versions

v4.4.stable.arch_linux

System information

Godot v4.4.stable unknown - Arch Linux #1 SMP PREEMPT_DYNAMIC Sat, 22 Feb 2025 00:37:05 +0000 on X11 - X11 display driver, Multi-window, 1 monitor - Vulkan (Forward+) - dedicated AMD Radeon RX 6600 (amdgpu) - 13th Gen Intel(R) Core(TM) i7-13700K (24 threads)

Issue description

Unique node names are awesome and I use them a lot.

So I thought, why isn't there a shortcut key to set Unique Name on a node in the editor? The extremely obvious candidate is %.

And then I thought, I can just assign it myself!

So I did:

Image

This is with Physical, but it also happens with Keycode and Key Label.

It shows up in the context menu when right-clicking on a node. But it does not work; nothing happens when I select a node and press % (i.e. Shift+5).

Steps to reproduce

See above.

Minimal reproduction project (MRP)

n/a

@AThousandShips
Copy link
Member

Does this happen when in the 2D editor only? It is used for a specific zoom level in that editor

@ttencate
Copy link
Contributor Author

ttencate commented Mar 25, 2025

Good thought, but unfortunately it also happens when I switch to 3D.

It still happens when I unassign the shortcuts Shift+5 and Shift+Kp 5 from "Zoom to 3.125%", and 5 and Kp 5 from "Zoom to 1600%" for good measure as well.

@kleonc
Copy link
Member

kleonc commented Mar 25, 2025

Tested in v4.4.stable.official [4c311cb], and in current master (v4.5.dev.custom_build [6b5b84c]):

It works / doesn't work based on what's focused. Right after the selecting nodes in the scene tree dock it doesn't work.

Here I'm constantly toggling it:
Image

Does this happen when in the 2D editor only? It is used for a specific zoom level in that editor

If 2D Viewport is focused (happens when moving mouse over it) it does work, it both sets the zoom and toggles unique name(s).

Image

@EricEzaM
Copy link
Contributor

EricEzaM commented Mar 25, 2025

This is what is happening:

  1. When input is received, nodes get gui_input called on them first, before shortcut_input.
  2. The Tree control used for the scene tree dock is handling gui_input and doing some processing.
  3. It sees that the key pressed is a valid unicode key, and so based on these conditions it does a incremental search for that unicode character.
  4. It performs an incremental search, and accepts the event. This prevents any further input processing.

This is the code being triggered, specifically the branch if (k->get_unicode() > 0) {

godot/scene/gui/tree.cpp

Lines 3678 to 3704 in a76c1ac

if (allow_search && k.is_valid()) { // Incremental search
if (!k->is_pressed()) {
return;
}
if (k->is_command_or_control_pressed() || (k->is_shift_pressed() && k->get_unicode() == 0) || k->is_meta_pressed()) {
return;
}
if (!root) {
return;
}
if (hide_root && !root->get_next_visible()) {
return;
}
if (k->get_unicode() > 0) {
_do_incr_search(String::chr(k->get_unicode()));
accept_event();
return;
} else {
if (k->get_keycode() != Key::SHIFT) {
last_keypress = 0;
}
}
}

What is happening is more clear if you change the shortcut to be Shift + 4 (unicode $) since if you try create a node %test, godot will remove the % and give it the unique name:

Image

I have created a node $test which as you can see in the video below, is selected when I press the shortcut (Shift + 4 = $) due to the incremental search for $.

godot.windows.editor.dev.x86_64_zZCSqDlfRt.mp4

Not sure what the solution is here. Probably "pick a different shortcut" but I know that sucks. Processing shortcuts before input is a huge change that would break many things so is not viable.

It works if you have the viewport focused, as the viewport does not do any pre-shortcut input handling of this key combination, and the shortcut ends up getting handled globally by the scene tree dock. Note this works for any focused control that has this behaviour, e.g. if you focus the inspector then the shortcut still works too (again, it is treated as being global)

@ttencate
Copy link
Contributor Author

That makes total sense, thank you for digging into this! I wasn't even aware of the incremental search feature, otherwise I'd have thought of it myself.

Closing as not feasible.

@ttencate ttencate closed this as not planned Won't fix, can't repro, duplicate, stale Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants