diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2018-01-04 14:56:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-04 14:56:29 +0100 |
commit | b997773b26ec944c4bc73a54aca8c9ccfe6d1119 (patch) | |
tree | 0701ad9fd6831e28a691c10dd4e15ab6e137c480 /editor | |
parent | dc2cc6bc2b2c5ca770675267bff98f434566866b (diff) | |
parent | 3f122672a2fb188f7d05c6e9b0a3e1125fb2c4f1 (diff) |
Merge pull request #15033 from poke1024/shortcuts-mac
Alternative keyboard shortcuts for macOS
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_settings.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index dc82a02f46..a5001cb1ac 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -1329,8 +1329,44 @@ Ref<ShortCut> ED_GET_SHORTCUT(const String &p_path) { return sc; } +struct ShortCutMapping { + const char *path; + uint32_t keycode; +}; + Ref<ShortCut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p_keycode) { +#ifdef OSX_ENABLED + static const ShortCutMapping macos_mappings[] = { + { "editor/play", KEY_MASK_CMD | KEY_B }, + { "editor/play_scene", KEY_MASK_CMD | KEY_R }, + { "editor/pause_scene", KEY_MASK_CMD | KEY_MASK_CTRL | KEY_Y }, + { "editor/stop", KEY_MASK_CMD | KEY_PERIOD }, + { "editor/play_custom_scene", KEY_MASK_SHIFT | KEY_MASK_CMD | KEY_R }, + { "editor/editor_2d", KEY_MASK_ALT | KEY_1 }, + { "editor/editor_3d", KEY_MASK_ALT | KEY_2 }, + { "editor/editor_script", KEY_MASK_ALT | KEY_3 }, + { "editor/editor_help", KEY_MASK_ALT | KEY_SPACE }, + { "editor/fullscreen_mode", KEY_MASK_CMD | KEY_MASK_CTRL | KEY_F }, + { "editor/distraction_free_mode", KEY_MASK_CMD | KEY_MASK_CTRL | KEY_D }, + { "script_text_editor/contextual_help", KEY_MASK_ALT | KEY_MASK_SHIFT | KEY_SPACE }, + { "script_text_editor/find_next", KEY_MASK_CMD | KEY_G }, + { "script_text_editor/find_previous", KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_G }, + { "script_text_editor/toggle_breakpoint", KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_B } + }; + + if (p_keycode == KEY_DELETE) { + p_keycode = KEY_MASK_CMD | KEY_BACKSPACE; + } else { + for (int i = 0; i < sizeof(macos_mappings) / sizeof(ShortCutMapping); i++) { + if (p_path == macos_mappings[i].path) { + p_keycode = macos_mappings[i].keycode; + break; + } + } + } +#endif + Ref<InputEventKey> ie; if (p_keycode) { ie.instance(); |