godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.54k stars 21.08k forks source link

Ctrl+Shift+Z action not triggering #71911

Open nezvers opened 1 year ago

nezvers commented 1 year ago

Godot version

4, Beta 14

System information

Windows 10

Issue description

Physical and non-physical Ctrl+Shift+Z does NOT work. Physical and non-physical Ctrl+Y works

ui_redo is triggering with Ctrl+Y but not with Ctrl+Shift+Z I tried to:

PS. It works for the Godot editor itself, it doesn't work for a game.

Steps to reproduce

Create a script that uses the action Ctrl+Shift+Z

Minimal reproduction project

Currently both actions as Physical from my QWERTY layout. Discovered while making this project. The action is used in the main.gd. DIY UndoRedo.zip

Vilcrow commented 1 year ago

@nezvers have you redefined the event ui_undo? The combination Ctrl+Shift+Z is set there. I redefine it and it works.

nezvers commented 1 year ago

@Vilcrow As I wrote in the description. I tried to:

It works for the Godot editor itself, it doesn't work for a game.

Calinou commented 1 year ago

This is due to non-QWERTY keyboard layouts being broken currently, possibly by https://github.com/godotengine/godot/pull/70052. cc @bruvzg

I can reproduce this in the editor on 4.0.beta 4fa6edc88 (French AZERTY layout on Linux). I have to press Ctrl + W instead of Ctrl + Z for undo to work.

bruvzg commented 1 year ago

70052 should not change behavior of shortcuts like this.

Tested on X11 and macOS with current master and beta 14 using QWERTY and AZERTY layouts, everything works in editor (undo/redo in the script editor). When running the project:

Seems like there is physical keycode Ctrl+Y and physical Shift+Ctrl+Z actions saved in the project.godot.

nezvers commented 1 year ago

Yes there is a physical keycode, because: Physical and non-physical Ctrl+Shift+Z does NOT work. At least on my QWERTY Windows machine. In the editor, it works. Physical and non-physical Ctrl+Y works

bruvzg commented 1 year ago

OK, found unrelated issue with a #70052 (will fix in a moment).

It works if it's done like this. Default behavior is exact_match = false, without exact_match = true it was matching Ctrl+Z to Ctrl+Shift+Z and triggering ui_undo first:

func _unhandled_input(event:InputEvent)->void:
    if event.is_action_pressed("ui_undo", false, true): # action name, allow echo, exact match
        print("Undo")
        undoRedoResource.undo()
    if event.is_action_pressed("ui_redo", false, true):
        print("Redo")
        undoRedoResource.redo()

So it's a feature, but I do not think it's a good thing to have by default.

nezvers commented 1 year ago

That seems extra frustrating either way - when action is pressed and it doesn't work or action gets triggered when there are held extra optional keys. Still, thank you, @bruvzg, for your help!

git2013vb commented 1 year ago

I have similar problem with different shortcuts setting a new one For example for Show in Filesystem If I set Ctrl+e as shortcut it will not trigger, instead it will write e in editor

v4.0.rc2.official [d2699dc7a] Debian 11

Rindbee commented 1 year ago

I have similar problem with different shortcuts setting a new one For example for Show in Filesystem If I set Ctrl+e as shortcut it will not trigger, instead it will write e in editor

Similar to #74181.