mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-19 06:07:42 +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 "../Project.h"
|
||||||
#include "../Theme.h"
|
#include "../Theme.h"
|
||||||
#include "../widgets/AButton.h"
|
#include "../widgets/AButton.h"
|
||||||
|
#include "../widgets/ASlider.h"
|
||||||
|
#include "../widgets/Meter.h"
|
||||||
#include "../widgets/Grabber.h"
|
#include "../widgets/Grabber.h"
|
||||||
|
|
||||||
#include "../Experimental.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
|
// Read the toolbar states
|
||||||
//
|
//
|
||||||
@ -1420,6 +1441,8 @@ void ToolManager::HandleEscapeKey()
|
|||||||
mDragWindow->Destroy();
|
mDragWindow->Destroy();
|
||||||
mDragWindow = nullptr;
|
mDragWindow = nullptr;
|
||||||
mDragBar->Refresh(false);
|
mDragBar->Refresh(false);
|
||||||
|
|
||||||
|
mPrevDock->SetFocus();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Floater remains, and returns to where it begain
|
// Floater remains, and returns to where it begain
|
||||||
@ -1455,4 +1478,20 @@ void ToolManager::DoneDragging()
|
|||||||
mTimer.Stop();
|
mTimer.Stop();
|
||||||
mDidDrag = false;
|
mDidDrag = false;
|
||||||
mClicked = 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 "../MemoryX.h"
|
||||||
#include <wx/defs.h>
|
#include <wx/defs.h>
|
||||||
|
#include <wx/eventfilter.h>
|
||||||
#include <wx/frame.h>
|
#include <wx/frame.h>
|
||||||
#include <wx/timer.h>
|
#include <wx/timer.h>
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ class ToolFrame;
|
|||||||
/// class ToolManager
|
/// class ToolManager
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class ToolManager final : public wxEvtHandler
|
class ToolManager final : public wxEvtHandler, public wxEventFilter
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -68,6 +69,8 @@ class ToolManager final : public wxEvtHandler
|
|||||||
void Reset();
|
void Reset();
|
||||||
void RegenerateTooltips();
|
void RegenerateTooltips();
|
||||||
|
|
||||||
|
int FilterEvent(wxEvent &event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
ToolBar *Float( ToolBar *t, wxPoint & pos );
|
ToolBar *Float( ToolBar *t, wxPoint & pos );
|
||||||
@ -88,6 +91,7 @@ class ToolManager final : public wxEvtHandler
|
|||||||
void Updated();
|
void Updated();
|
||||||
|
|
||||||
AudacityProject *mParent;
|
AudacityProject *mParent;
|
||||||
|
wxWindow *mLastFocus{};
|
||||||
|
|
||||||
ToolFrame *mDragWindow;
|
ToolFrame *mDragWindow;
|
||||||
ToolDock *mDragDock;
|
ToolDock *mDragDock;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user