From 959767c09f28cf3a4687d570689dc9ef1860e8fe Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 16 Jan 2018 23:48:13 +0000 Subject: [PATCH] Don't warp mouse when context menu was cancelled. Fixes: lp:1674199 * https://bugs.launchpad.net/kicad/+bug/1674199 --- common/draw_panel.cpp | 14 +++----------- eeschema/controle.cpp | 17 ++++++++++++++--- eeschema/onrightclick.cpp | 9 +++------ eeschema/schframe.h | 3 ++- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/common/draw_panel.cpp b/common/draw_panel.cpp index bce9376fc8..da60ffb5fb 100644 --- a/common/draw_panel.cpp +++ b/common/draw_panel.cpp @@ -906,18 +906,10 @@ bool EDA_DRAW_PANEL::OnRightClick( wxMouseEvent& event ) pos = event.GetPosition(); m_ignoreMouseEvents = true; PopupMenu( &MasterMenu, pos ); - // here, we are waiting for popup menu closing. - // Among different ways, it can be closed by clicking on the left mouse button. - // The expected behavior is to move the mouse cursor to its initial - // location, where the right click was made. - // However there is a case where the move cursor does not work as expected: - // when the user left clicks on the caption frame: the entire window is moved. - // Calling wxSafeYield avoid this behavior because it allows the left click - // to be proceeded before moving the mouse - wxSafeYield(); - // Move the mouse cursor to its initial position: - MoveCursorToCrossHair(); + // The ZoomAndGrid menu is only invoked over empty space so there's no point in warping + // the cursor back to the crosshair, and it's very annoying if one clicked out of the menu. + m_ignoreMouseEvents = false; return true; diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp index 2876b965d3..37381007e6 100644 --- a/eeschema/controle.cpp +++ b/eeschema/controle.cpp @@ -50,7 +50,8 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KICAD_T aFilterList[], - int aHotKeyCommandId ) + int aHotKeyCommandId, + bool* clarificationMenuCancelled ) { SCH_ITEM* item; LIB_PIN* Pin = NULL; @@ -65,6 +66,9 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC // off grid position. if( !item && m_canvas->GetAbortRequest() ) { + if( clarificationMenuCancelled ) + *clarificationMenuCancelled = true; + m_canvas->SetAbortRequest( false ); return NULL; } @@ -74,6 +78,9 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC if( !item ) { + if( clarificationMenuCancelled ) + *clarificationMenuCancelled = m_canvas->GetAbortRequest(); + m_canvas->SetAbortRequest( false ); // Just in case the user aborted the context menu. return NULL; } @@ -189,8 +196,12 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, const KICAD_T aF GetScreen()->SetCurItem( NULL ); m_canvas->SetAbortRequest( true ); // Changed to false if an item is selected PopupMenu( &selectMenu ); - m_canvas->MoveCursorToCrossHair(); - item = GetScreen()->GetCurItem(); + + if( !m_canvas->GetAbortRequest() ) + { + m_canvas->MoveCursorToCrossHair(); + item = GetScreen()->GetCurItem(); + } } } diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index e7a26063bd..9b74920a06 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -75,6 +75,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) SCH_ITEM* item = GetScreen()->GetCurItem(); bool blockActive = GetScreen()->IsBlockActive(); wxString msg; + bool actionCancelled = false; // Do not start a block command on context menu. m_canvas->SetCanStartBlock( -1 ); @@ -138,18 +139,14 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) // Try to locate items at cursor position. if( (item == NULL) || (item->GetFlags() == 0) ) { - item = LocateAndShowItem( aPosition, SCH_COLLECTOR::AllItemsButPins ); + item = LocateAndShowItem( aPosition, SCH_COLLECTOR::AllItemsButPins, 0, &actionCancelled ); // If the clarify item selection context menu is aborted, don't show the context menu. - if( item == NULL && m_canvas->GetAbortRequest() ) - { - m_canvas->SetAbortRequest( false ); + if( item == NULL && actionCancelled ) return false; - } } // If a command is in progress: add "cancel" and "end tool" menu - // If if( GetToolId() != ID_NO_TOOL_SELECTED ) { if( item && item->GetFlags() ) diff --git a/eeschema/schframe.h b/eeschema/schframe.h index eba05d35a7..a5454161c1 100644 --- a/eeschema/schframe.h +++ b/eeschema/schframe.h @@ -407,7 +407,8 @@ public: */ SCH_ITEM* LocateAndShowItem( const wxPoint& aPosition, const KICAD_T aFilterList[] = SCH_COLLECTOR::AllItems, - int aHotKeyCommandId = 0 ); + int aHotKeyCommandId = 0, + bool* clarifySelectionMenuCancelled = nullptr ); /** * Check for items at \a aPosition matching the types in \a aFilterList.