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

Script editor ignores Alt + key shortcuts and inserts special character instead #63888

Open
sbalia opened this issue Aug 3, 2022 · 7 comments

Comments

@sbalia
Copy link

sbalia commented Aug 3, 2022

Godot version

3.4.5.stable.mono

System information

MacOS

Issue description

When you are in the editor, in the script editor, after pressing Alt + 1 (Opt + 1) – Open 2D Editor, or Alt + 2 – Open 3D editor, etc. Whatever combination that requires you to press Alt + number or letter (by the way, Alt + Space inserts space), it will insert a special characters.

I'd expect these shortcuts not to be ignored.

After a quick lookup in the codebase, when you press one of the shortcuts, it only hits: void FindReplaceBar::_editor_text_changed() from the code_editor.cpp file.

These calls are being ignored (editor_node.cpp):

if (ED_IS_SHORTCUT("editor/editor_2d", p_event)) {
    _editor_select(EDITOR_2D);
} else if (ED_IS_SHORTCUT("editor/editor_3d", p_event)) {
    _editor_select(EDITOR_3D);
} else if (ED_IS_SHORTCUT("editor/editor_script", p_event)) {
    _editor_select(EDITOR_SCRIPT);

I'm not a C++ guru neither not so familiar with the project. Therefore I assume it was implemented intentionally.
I can try to fix that, but at the moment, I don't understand why those shortcut calls have "less priority" than "text_changed event".

There are two workarounds:

  1. Have the same shortcuts as for windows, at least the second part: Alt + F1, Alt + F2, and so on.
  2. Change bindings in the editor settings.

Maybe there is also an option to disable it in macOS.

NB: It doesn't work only from the script editor. It works if you are on the 2D Editor and want to jump to the script editor (Alt + 3).

It might be a related issue: #23548

Steps to reproduce

  1. Open the script editor;
  2. Try to press Alt + 1, Alt + 2, Alt + Space.

Minimal reproduction project

No response

@bruvzg
Copy link
Member

bruvzg commented Aug 3, 2022

It's fixed in 4.0 - #56695, but not in 3.x. But we probably should remove all Alt + number/letter shortcuts, since in many keyboard layouts these are used for inputting special characters.

@sbalia
Copy link
Author

sbalia commented Aug 3, 2022

@bruvzg,
Awesome. Then, shall I close this issue?

@Calinou
Copy link
Member

Calinou commented Aug 3, 2022

Awesome. Then, shall I close this issue?

We should still try to fix this issue for 3.x, even if it means changing some of the default shortcuts on macOS.

@sbalia
Copy link
Author

sbalia commented Aug 4, 2022

@Calinou, @bruvzg, are there any guidelines on how to define shortcuts? Or do you have any suggestions for the implementation? To be consistent with other shortcuts but adapted to macOS.

@Calinou, what did you mean "even if it means changing some of the default shortcuts on macOS"?

@bruvzg
Copy link
Member

bruvzg commented Aug 4, 2022

Something probably should be done, but Godot uses a lot of shortcuts, it won't be that easy to ensure every one is fine and working in all conditions.

are there any guidelines on how to define shortcuts?

https://developer.apple.com/design/human-interface-guidelines/inputs/keyboards#custom-keyboard-shortcuts

even if it means changing some of the default shortcuts on macOS

We can define different shortcuts for macOS and other platforms (we already do, when shortcut conflicts with OS default shortcut), we can do the same here.

@Calinou Calinou changed the title Script editor is ignoring part of the Alt + key shortcuts in MacOS. Script editor ignores Alt + key shortcuts and inserts special character instead Aug 4, 2022
@lostminds
Copy link

Would just like to add my experience to this. I just started playing around with Godot beta 4 and on my Swedish keyboard @ is option (alt)-2. Since the above "bug" is now fixed, this means that every time I tried to type @ in a script Godot would switch me out of the script editor.

I agree with @bruvzg that for me as a macOS user in general shortcuts would be expected to be command-something, and in particular I think it's a bad idea to not interpret option/shift-character combinations as special characters when typing in a field editor, since a lot of languages use these kinds of special characters.

So I think reverting to the previous behavior as I understand it from above, where alt-shortcuts would be used as character entry in text fields would be a good idea short-term, and longer term changing all default shortcuts you might want to use while text editing (like tab navigation) to control- or command- shortcuts to make sure they aren't in conflict with character entry.

@lostminds
Copy link

Another related inconsistency in Godot 4.0.beta4:
In the script code editor and when editing node text parameter fields in the inspector this works as expected (Command-S shortcut saves and doesn't modify the text). But if you edit a node name in the Scene node tree Command-S both types an "s" in the field and saves the file.

On macOS I think a good convention is that command-keyboard shortcuts should never be interpreted as text entry, and the same probably goes for Control-keyboard on Windows.

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

4 participants