From b18601dfc6dc93d2b634100b09629b607b083785 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 20 Sep 2017 19:41:59 +0200 Subject: [PATCH] Send wxEVENT_CHAR to GUI (if the key is not a special key that scrolls the draw panel) both on Linux and Windows fix lp:1718488 --- common/tool/tool_dispatcher.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/common/tool/tool_dispatcher.cpp b/common/tool/tool_dispatcher.cpp index 9f8b484ec3..5c9113fbba 100644 --- a/common/tool/tool_dispatcher.cpp +++ b/common/tool/tool_dispatcher.cpp @@ -309,6 +309,7 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent ) bool motion = false, buttonEvents = false; boost::optional evt; int key = 0; // key = 0 if the event is not a key event + bool keyIsSpecial = false; // True if the key is a special key code int type = aEvent.GetEventType(); @@ -357,13 +358,14 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent ) { wxKeyEvent* ke = static_cast( &aEvent ); key = ke->GetKeyCode(); + keyIsSpecial = isKeySpecialCode( key ); // if the key event must be skipped, skip it here if the event is a wxEVT_CHAR_HOOK // and do nothing. // a wxEVT_CHAR will be fired by wxWidgets later for this key. if( type == wxEVT_CHAR_HOOK ) { - if( !isKeySpecialCode( key ) ) + if( !keyIsSpecial ) { aEvent.Skip(); return; @@ -406,18 +408,18 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent ) // in pcbnew and the footprint editor any time a hotkey is used. The correct procedure is // to NOT pass wxEVT_CHAR events to the GUI under OS X. // - // On Windows, avoid to call wxEvent::Skip because some keys (ARROWS, PAGE_UP, PAGE_DOWN + // On Windows, avoid to call wxEvent::Skip for special keys because some keys (ARROWS, PAGE_UP, PAGE_DOWN // have predefined actions (like move thumbtrack cursor), and we do not want these // actions executed (most are handled by Kicad) if( !evt || type == wxEVT_LEFT_DOWN ) aEvent.Skip(); - // On Linux, the suitable Skip is already called, but the wxEVT_CHAR + // The suitable Skip is already called, but the wxEVT_CHAR // must be Skipped (sent to GUI). - // Otherwise accelerators are not seen. -#ifdef __LINUX__ - if( type == wxEVT_CHAR ) + // Otherwise accelerators and shortcuts in main menu or toolbars are not seen. +#ifndef __APPLE__ + if( type == wxEVT_CHAR && !keyIsSpecial ) aEvent.Skip(); #endif