On macOS, change some default editor shortcuts
This commit is contained in:
parent
256a60bc6e
commit
3f122672a2
|
@ -1316,8 +1316,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();
|
||||
|
|
|
@ -99,10 +99,28 @@ static Vector2 get_mouse_pos(NSEvent *event) {
|
|||
|
||||
@implementation GodotApplication
|
||||
|
||||
- (void)sendEvent:(NSEvent *)event {
|
||||
|
||||
// special case handling of command-period, which is traditionally a special
|
||||
// shortcut in macOS and doesn't arrive at our regular keyDown handler.
|
||||
if ([event type] == NSKeyDown) {
|
||||
if (([event modifierFlags] & NSEventModifierFlagCommand) && [event keyCode] == 0x2f) {
|
||||
|
||||
Ref<InputEventKey> k;
|
||||
k.instance();
|
||||
|
||||
get_key_modifier_state([event modifierFlags], k);
|
||||
k->set_pressed(true);
|
||||
k->set_scancode(KEY_PERIOD);
|
||||
k->set_echo([event isARepeat]);
|
||||
|
||||
OS_OSX::singleton->push_input(k);
|
||||
}
|
||||
}
|
||||
|
||||
// From http://cocoadev.com/index.pl?GameKeyboardHandlingAlmost
|
||||
// This works around an AppKit bug, where key up events while holding
|
||||
// down the command key don't get sent to the key window.
|
||||
- (void)sendEvent:(NSEvent *)event {
|
||||
if ([event type] == NSKeyUp && ([event modifierFlags] & NSCommandKeyMask))
|
||||
[[self keyWindow] sendEvent:event];
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue