Cancel drag action when focus is lost

This commit is contained in:
mitxela 2021-01-24 17:17:51 +00:00 committed by Jon Evans
parent bb79eb0e45
commit 886cad43bd
3 changed files with 18 additions and 0 deletions

View File

@ -545,6 +545,8 @@ void EDA_DRAW_PANEL_GAL::onLostFocus( wxFocusEvent& aEvent )
{ {
m_lostFocus = true; m_lostFocus = true;
m_viewControls->CancelDrag();
aEvent.Skip(); aEvent.Skip();
} }

View File

@ -598,6 +598,19 @@ void WX_VIEW_CONTROLS::CaptureCursor( bool aEnabled )
} }
void WX_VIEW_CONTROLS::CancelDrag()
{
if( m_state == DRAG_PANNING || m_state == DRAG_ZOOMING )
{
m_state = IDLE;
#if defined USE_MOUSE_CAPTURE
if( !m_settings.m_cursorCaptured && m_parentPanel->HasCapture() )
m_parentPanel->ReleaseMouse();
#endif
}
}
VECTOR2D WX_VIEW_CONTROLS::GetMousePosition( bool aWorldCoordinates ) const VECTOR2D WX_VIEW_CONTROLS::GetMousePosition( bool aWorldCoordinates ) const
{ {
wxPoint msp = getMouseScreenPosition(); wxPoint msp = getMouseScreenPosition();

View File

@ -102,6 +102,9 @@ public:
///< Adjusts the scrollbars position to match the current viewport. ///< Adjusts the scrollbars position to match the current viewport.
void UpdateScrollbars(); void UpdateScrollbars();
///< End any mouse drag action still in progress
void CancelDrag();
void ForceCursorPosition( bool aEnabled, void ForceCursorPosition( bool aEnabled,
const VECTOR2D& aPosition = VECTOR2D( 0, 0 ) ) override; const VECTOR2D& aPosition = VECTOR2D( 0, 0 ) ) override;