mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-17 09:07:41 +02:00
Bug1432, more: Restore focused control after drag of toolbar
This commit is contained in:
parent
ace1ac08e7
commit
1a9dd310cd
@ -67,6 +67,8 @@
|
||||
#include "../Project.h"
|
||||
#include "../Theme.h"
|
||||
#include "../widgets/AButton.h"
|
||||
#include "../widgets/ASlider.h"
|
||||
#include "../widgets/Meter.h"
|
||||
#include "../widgets/Grabber.h"
|
||||
|
||||
#include "../Experimental.h"
|
||||
@ -639,6 +641,25 @@ void ToolManager::RegenerateTooltips()
|
||||
}
|
||||
}
|
||||
|
||||
int ToolManager::FilterEvent(wxEvent &event)
|
||||
{
|
||||
// Snoop the global event stream for changes of focused window. Remember
|
||||
// the last one of our own that is not a grabber.
|
||||
|
||||
if (event.GetEventType() == wxEVT_SET_FOCUS) {
|
||||
auto &focusEvent = static_cast<wxFocusEvent&>(event);
|
||||
auto window = focusEvent.GetWindow();
|
||||
if ( !dynamic_cast<Grabber*>( window ) &&
|
||||
wxGetTopLevelParent(window) == mParent )
|
||||
mLastFocus = window;
|
||||
}
|
||||
else if (event.GetEventType() == wxEVT_KILL_FOCUS)
|
||||
// Avoid a dangling pointer!
|
||||
mLastFocus = nullptr;
|
||||
|
||||
return Event_Skip;
|
||||
}
|
||||
|
||||
//
|
||||
// Read the toolbar states
|
||||
//
|
||||
@ -1420,6 +1441,8 @@ void ToolManager::HandleEscapeKey()
|
||||
mDragWindow->Destroy();
|
||||
mDragWindow = nullptr;
|
||||
mDragBar->Refresh(false);
|
||||
|
||||
mPrevDock->SetFocus();
|
||||
}
|
||||
else {
|
||||
// Floater remains, and returns to where it begain
|
||||
@ -1455,4 +1478,20 @@ void ToolManager::DoneDragging()
|
||||
mTimer.Stop();
|
||||
mDidDrag = false;
|
||||
mClicked = false;
|
||||
|
||||
if (mPrevFocus) {
|
||||
auto parent = mPrevFocus->GetParent();
|
||||
if (parent) {
|
||||
// Two lines we seem to need on Mac with wx3, for reasons unknown
|
||||
//parent->SetFocus();
|
||||
//parent->NavigateIn();
|
||||
|
||||
// What we really want just to reestablish old focus
|
||||
auto temp1 = AButton::TemporarilyAllowFocus();
|
||||
auto temp2 = ASlider::TemporarilyAllowFocus();
|
||||
auto temp3 = Meter::TemporarilyAllowFocus();
|
||||
mPrevFocus->SetFocus();
|
||||
}
|
||||
}
|
||||
mPrevFocus = nullptr;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "../MemoryX.h"
|
||||
#include <wx/defs.h>
|
||||
#include <wx/eventfilter.h>
|
||||
#include <wx/frame.h>
|
||||
#include <wx/timer.h>
|
||||
|
||||
@ -41,7 +42,7 @@ class ToolFrame;
|
||||
/// class ToolManager
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
class ToolManager final : public wxEvtHandler
|
||||
class ToolManager final : public wxEvtHandler, public wxEventFilter
|
||||
{
|
||||
|
||||
public:
|
||||
@ -68,6 +69,8 @@ class ToolManager final : public wxEvtHandler
|
||||
void Reset();
|
||||
void RegenerateTooltips();
|
||||
|
||||
int FilterEvent(wxEvent &event) override;
|
||||
|
||||
private:
|
||||
|
||||
ToolBar *Float( ToolBar *t, wxPoint & pos );
|
||||
@ -88,6 +91,7 @@ class ToolManager final : public wxEvtHandler
|
||||
void Updated();
|
||||
|
||||
AudacityProject *mParent;
|
||||
wxWindow *mLastFocus{};
|
||||
|
||||
ToolFrame *mDragWindow;
|
||||
ToolDock *mDragDock;
|
||||
|
Loading…
x
Reference in New Issue
Block a user