Don't warp mouse when context menu was cancelled.

Fixes: lp:1674199
* https://bugs.launchpad.net/kicad/+bug/1674199
This commit is contained in:
Jeff Young 2018-01-16 23:48:13 +00:00 committed by Wayne Stambaugh
parent 8721f7ed70
commit 959767c09f
4 changed files with 22 additions and 21 deletions

View File

@ -906,18 +906,10 @@ bool EDA_DRAW_PANEL::OnRightClick( wxMouseEvent& event )
pos = event.GetPosition(); pos = event.GetPosition();
m_ignoreMouseEvents = true; m_ignoreMouseEvents = true;
PopupMenu( &MasterMenu, pos ); 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: // The ZoomAndGrid menu is only invoked over empty space so there's no point in warping
MoveCursorToCrossHair(); // the cursor back to the crosshair, and it's very annoying if one clicked out of the menu.
m_ignoreMouseEvents = false; m_ignoreMouseEvents = false;
return true; return true;

View File

@ -50,7 +50,8 @@
SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KICAD_T aFilterList[], SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KICAD_T aFilterList[],
int aHotKeyCommandId ) int aHotKeyCommandId,
bool* clarificationMenuCancelled )
{ {
SCH_ITEM* item; SCH_ITEM* item;
LIB_PIN* Pin = NULL; LIB_PIN* Pin = NULL;
@ -65,6 +66,9 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC
// off grid position. // off grid position.
if( !item && m_canvas->GetAbortRequest() ) if( !item && m_canvas->GetAbortRequest() )
{ {
if( clarificationMenuCancelled )
*clarificationMenuCancelled = true;
m_canvas->SetAbortRequest( false ); m_canvas->SetAbortRequest( false );
return NULL; return NULL;
} }
@ -74,6 +78,9 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC
if( !item ) if( !item )
{ {
if( clarificationMenuCancelled )
*clarificationMenuCancelled = m_canvas->GetAbortRequest();
m_canvas->SetAbortRequest( false ); // Just in case the user aborted the context menu. m_canvas->SetAbortRequest( false ); // Just in case the user aborted the context menu.
return NULL; return NULL;
} }
@ -189,8 +196,12 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, const KICAD_T aF
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
m_canvas->SetAbortRequest( true ); // Changed to false if an item is selected m_canvas->SetAbortRequest( true ); // Changed to false if an item is selected
PopupMenu( &selectMenu ); PopupMenu( &selectMenu );
m_canvas->MoveCursorToCrossHair();
item = GetScreen()->GetCurItem(); if( !m_canvas->GetAbortRequest() )
{
m_canvas->MoveCursorToCrossHair();
item = GetScreen()->GetCurItem();
}
} }
} }

View File

@ -75,6 +75,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
SCH_ITEM* item = GetScreen()->GetCurItem(); SCH_ITEM* item = GetScreen()->GetCurItem();
bool blockActive = GetScreen()->IsBlockActive(); bool blockActive = GetScreen()->IsBlockActive();
wxString msg; wxString msg;
bool actionCancelled = false;
// Do not start a block command on context menu. // Do not start a block command on context menu.
m_canvas->SetCanStartBlock( -1 ); 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. // Try to locate items at cursor position.
if( (item == NULL) || (item->GetFlags() == 0) ) 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 the clarify item selection context menu is aborted, don't show the context menu.
if( item == NULL && m_canvas->GetAbortRequest() ) if( item == NULL && actionCancelled )
{
m_canvas->SetAbortRequest( false );
return false; return false;
}
} }
// If a command is in progress: add "cancel" and "end tool" menu // If a command is in progress: add "cancel" and "end tool" menu
// If
if( GetToolId() != ID_NO_TOOL_SELECTED ) if( GetToolId() != ID_NO_TOOL_SELECTED )
{ {
if( item && item->GetFlags() ) if( item && item->GetFlags() )

View File

@ -407,7 +407,8 @@ public:
*/ */
SCH_ITEM* LocateAndShowItem( const wxPoint& aPosition, SCH_ITEM* LocateAndShowItem( const wxPoint& aPosition,
const KICAD_T aFilterList[] = SCH_COLLECTOR::AllItems, 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. * Check for items at \a aPosition matching the types in \a aFilterList.