From f47013286219064a07df3faeeb94ac1dc7cfb29c Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 26 Aug 2018 18:56:29 +0100 Subject: [PATCH] Fix fast grid switching for OSX and Footprint Editor. Fixes: lp:1787066 * https://bugs.launchpad.net/kicad/+bug/1787066 --- common/tool/tool_dispatcher.cpp | 26 ++++++++++++++++++++++++++ pcbnew/hotkeys.cpp | 6 ++++++ 2 files changed, 32 insertions(+) diff --git a/common/tool/tool_dispatcher.cpp b/common/tool/tool_dispatcher.cpp index d1571dd4aa..ba9c870ec8 100644 --- a/common/tool/tool_dispatcher.cpp +++ b/common/tool/tool_dispatcher.cpp @@ -399,6 +399,32 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent ) key += 'A' - 1; } +#ifdef __APPLE__ + if( mods & MD_ALT ) + { + // OSX maps a bunch of commonly used extended-ASCII characters onto the keyboard + // using the ALT key. Since we use ALT for some of our hotkeys, we need to map back + // to the underlying keys. The kVK_ANSI_* values come from Apple and are said to be + // hardware independant. + switch( ke->GetRawKeyCode() ) + { + case /* kVK_ANSI_1 */ 0x12: key = '1'; break; + case /* kVK_ANSI_2 */ 0x13: key = '2'; break; + case /* kVK_ANSI_3 */ 0x14: key = '3'; break; + case /* kVK_ANSI_4 */ 0x15: key = '4'; break; + case /* kVK_ANSI_6 */ 0x16: key = '6'; break; + case /* kVK_ANSI_5 */ 0x17: key = '5'; break; + case /* kVK_ANSI_Equal */ 0x18: key = '='; break; + case /* kVK_ANSI_9 */ 0x19: key = '9'; break; + case /* kVK_ANSI_7 */ 0x1A: key = '7'; break; + case /* kVK_ANSI_Minus */ 0x1B: key = '-'; break; + case /* kVK_ANSI_8 */ 0x1C: key = '8'; break; + case /* kVK_ANSI_0 */ 0x1D: key = '0'; break; + default: ; + } + } +#endif + if( key == WXK_ESCAPE ) // ESC is the special key for canceling tools evt = TOOL_EVENT( TC_COMMAND, TA_CANCEL_TOOL ); else diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index 4e4beaa6d4..02bc4f30a2 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -480,6 +480,12 @@ EDA_HOTKEY* module_edit_Hotkey_List[] = { &HkDuplicateItemAndIncrement, &HkCreateArray, + // Grids + &HkSwitchGridToFastGrid1, + &HkSwitchGridToFastGrid2, + &HkSwitchGridToNext, + &HkSwitchGridToPrevious, + // Display &HkSwitchHighContrastMode, &HkCanvasDefault,