Reset tool dispatcher state when GAL canvas loses focus

When the GAL canvas loses focus while a mouse button is pressed,
the button-up event may be delivered to another window, leaving
the tool dispatcher in an inconsistent state where it thinks the
button is still pressed. This can cause selection and drag
operations to stop working until the application is restarted.

Call ResetState() on the tool dispatcher when focus is lost to
ensure the button tracking state is properly cleared. This
complements the existing CancelDrag() call which only resets the
view-level panning/zooming state.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/22317

(cherry picked from commit f5731f69b1)
This commit is contained in:
Seth Hillbrand
2026-01-02 22:33:10 -08:00
parent 18575df311
commit 133d2fa5f6
+6
View File
@@ -626,6 +626,12 @@ void EDA_DRAW_PANEL_GAL::onLostFocus( wxFocusEvent& aEvent )
m_viewControls->CancelDrag();
// Reset the tool dispatcher's button state when focus is lost. This prevents
// the dispatcher from thinking the button is still pressed when focus returns,
// which can cause selection and drag operations to stop working.
if( m_eventDispatcher )
m_eventDispatcher->ResetState();
aEvent.Skip();
}