godotengine / godot

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

Custom shortcuts Shift+Alt+I for ui_text_caret_line_end not working #91067

Open EricJeffrey opened 4 months ago

EricJeffrey commented 4 months ago

Tested versions

Reproducible in Godot 4.2.1 and master-4a0160241fd0c1e874e297f6b08676cf0761e5e8.

System information

Windows 10 - Godot v4.2.1 Vulkan 1.3.277 - Forward+

Issue description

I was learning Godot for game develop and try to add a custom shortcuts Shift+Alt+I to move cursor to line end. After I add the shortcuts in editor settings, I just found it is not working. image

I also tried to build the latest Godot source code (HEAD at commit 4a0160241fd0c1e874e297f6b08676cf0761e5e8) and it's still not working.

Then I just dig into the Godot source code, and found (maybe not correct) that the shift key is unset when checking the caret_line_end action. image

Is this the bug? Or there is just another way to solve this?

Steps to reproduce

Open or create any project. Open editor settings and add shortcuts Shift+Alt+I for ui_text_caret_line_end. Open any script and put the caret in the middle of a sentence. Press Shift+Alt+I, expect caret moved to line end, but found nothing happended

Minimal reproduction project (MRP)

foo.zip Just an empty project with a script attached to root node is enough.

EricJeffrey commented 4 months ago

image

I just tried this and it will make Shift+Alt+I working as expected.

kitbdev commented 1 month ago

This happens because the shift key is used as a modifier to select text instead of just move the caret. Changing the condition to make sure alt is not pressed would cause issues when using Alt and not Shift for a shortcut, and you won't be able to select to the line end with your Shift+Alt+I. To fix this we would probably need to have a second set of actions for selecting for each one instead of having shift as a modifier, like ui_text_caret_select_right and ui_text_caret_select_line_end.