godotengine / godot

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

Script editor not respecting MacOS remapping of HOME/END key on MacOS #58566

Open pallaire opened 2 years ago

pallaire commented 2 years ago

Godot version

v3.4.2.stable.official [45eaa2daf]

System information

MacOS 12.2.1

Issue description

On MacOS you can remap keys behaviors by creating a special file in your library: $HOME/Library/KeyBindings/DefaultKeyBinding.dict

You can see here: https://discussions.apple.com/thread/251108215

Many older devs like me, reconfigure the HOME/END keys to behave like they do on Windows/Linux i.e. goto beginning/end of line. This remapping is not followed by Godot, but it is by every other apps on MacOS.

Solutions:

  1. Support the configured behavior in MacOS (with or without remapping)
  2. Add an entry in the shortcut editor preferences' page to enable remapping "Goto beginning/end of line" for the script editor.

I'm guessing that #2 might be easier to do.

Steps to reproduce

On MacOS, in Godot Plug a keyboard with HOME/END keys Remapped those keys to behave like they do on Windows: https://discussions.apple.com/thread/251108215 Edit any scripts Tap on HOME or END and notice that the cursor is sent to the beginning/end of the file instead than being sent to the beginning/end of the line.

Minimal reproduction project

Any script will do.

Calinou commented 2 years ago

cc @bruvzg

Add an entry in the shortcut editor preferences' page to enable remapping "Goto beginning/end of line" for the script editor.

This might be possible in 4.0alpha already (as pretty much every key is remappable there), but it may still be hardcoded in 3.x.

bruvzg commented 2 years ago

In the 4.0, it's remarkable using ui_text_caret_document_start/_end and ui_text_caret_line_start/_end actions. In 3.x it's hard-coded in the controls.

DefaultKeyBinding.dict is used by native Cocoa text edit controls, Godot do not use them in any way. We can read and parse it and set default actions, but I'm not sure if it's worth implementing.