1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-06 14:52:34 +02:00

Tool bar resizes orig focus at mouse up or ESC key, at least on Mac

This commit is contained in:
Paul Licameli 2016-07-02 10:48:07 -04:00
parent dab59cb79d
commit 28011280d0

View File

@ -87,6 +87,7 @@ private:
ToolBar *mBar; ToolBar *mBar;
wxPoint mResizeStart; wxPoint mResizeStart;
wxSize mOrigSize; wxSize mOrigSize;
wxWindow *mOrigFocus{};
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
}; };
@ -175,6 +176,9 @@ void ToolBarResizer::OnLeftUp( wxMouseEvent & event )
if( HasCapture() ) if( HasCapture() )
{ {
ReleaseMouse(); ReleaseMouse();
if (mOrigFocus)
mOrigFocus->SetFocus();
mOrigFocus = nullptr;
} }
} }
@ -185,6 +189,8 @@ void ToolBarResizer::OnEnter( wxMouseEvent & event )
const auto text = GetToolTipText(); const auto text = GetToolTipText();
UnsetToolTip(); UnsetToolTip();
SetToolTip(text); SetToolTip(text);
if (!mOrigFocus)
mOrigFocus = FindFocus();
} }
void ToolBarResizer::OnMotion( wxMouseEvent & event ) void ToolBarResizer::OnMotion( wxMouseEvent & event )
@ -248,6 +254,9 @@ void ToolBarResizer::OnCaptureLost( wxMouseCaptureLostEvent & WXUNUSED(event) )
if( HasCapture() ) if( HasCapture() )
{ {
ReleaseMouse(); ReleaseMouse();
if (mOrigFocus)
mOrigFocus->SetFocus();
mOrigFocus = nullptr;
} }
} }
@ -257,6 +266,9 @@ void ToolBarResizer::OnKeyDown(wxKeyEvent &event)
if (HasCapture() && WXK_ESCAPE == event.GetKeyCode()) { if (HasCapture() && WXK_ESCAPE == event.GetKeyCode()) {
ResizeBar( mOrigSize ); ResizeBar( mOrigSize );
ReleaseMouse(); ReleaseMouse();
if (mOrigFocus)
mOrigFocus->SetFocus();
mOrigFocus = nullptr;
} }
} }