mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-20 14:20:06 +02:00
Bug1432 partial, keep correct focus in more cases, not all...
Works by using the newer and better logic of ToolManager for remembering which window to focus. It seems, at least on Windows, that when the toolbar with the focused control is docked after the end of a docking (of itself or another bar), then focus remains. If the bar with the focus is undocked and another bar docks or undocks, focus is still lost.
This commit is contained in:
parent
9aea0d3967
commit
503f3548a1
@ -1351,10 +1351,6 @@ void AudacityProject::UpdatePrefs()
|
||||
if (mRuler) {
|
||||
mRuler->UpdatePrefs();
|
||||
}
|
||||
|
||||
// The toolbars will be recreated, so make sure we don't leave
|
||||
// a stale pointer hanging around.
|
||||
mLastFocusedWindow = NULL;
|
||||
}
|
||||
|
||||
void AudacityProject::SetMissingAliasFileDialog(wxDialog *dialog)
|
||||
@ -2416,11 +2412,6 @@ void AudacityProject::OnActivate(wxActivateEvent & event)
|
||||
|
||||
mActive = event.GetActive();
|
||||
|
||||
#if defined(__WXGTK__)
|
||||
// See bug #294 for explanation
|
||||
mTrackPanel->SetFocus();
|
||||
#endif
|
||||
|
||||
// Under Windows, focus can be "lost" when returning to
|
||||
// Audacity from a different application.
|
||||
//
|
||||
@ -2428,17 +2419,11 @@ void AudacityProject::OnActivate(wxActivateEvent & event)
|
||||
// then ALT+TAB to return to Audacity. Focus will be given to the
|
||||
// project window frame which is not at all useful.
|
||||
//
|
||||
// So, when the project window receives a deactivate event, we
|
||||
// remember which child had the focus. Then, when we receive the
|
||||
// So, we use ToolManager's observation of focus changes in a wxEventFilter.
|
||||
// Then, when we receive the
|
||||
// activate event, we restore that focus to the child or the track
|
||||
// panel if no child had the focus (which probably should never happen).
|
||||
if (!mActive) {
|
||||
// We only want to remember the last focused window if FindFocus() returns
|
||||
// a window within the current project frame.
|
||||
wxWindow *w = FindFocus();
|
||||
if (wxGetTopLevelParent(w) ==this) {
|
||||
mLastFocusedWindow = w;
|
||||
}
|
||||
#ifdef __WXMAC__
|
||||
if (IsIconized())
|
||||
MacShowUndockedToolbars(false);
|
||||
@ -2446,16 +2431,11 @@ void AudacityProject::OnActivate(wxActivateEvent & event)
|
||||
}
|
||||
else {
|
||||
SetActiveProject(this);
|
||||
if (mLastFocusedWindow) {
|
||||
mLastFocusedWindow->SetFocus();
|
||||
}
|
||||
else {
|
||||
if ( ! GetToolManager()->RestoreFocus() ) {
|
||||
if (mTrackPanel) {
|
||||
mTrackPanel->SetFocus();
|
||||
}
|
||||
}
|
||||
// No longer need to remember the last focused window
|
||||
mLastFocusedWindow = NULL;
|
||||
|
||||
#ifdef __WXMAC__
|
||||
MacShowUndockedToolbars(true);
|
||||
@ -2616,7 +2596,6 @@ void AudacityProject::OnCloseWindow(wxCloseEvent & event)
|
||||
// its size change.
|
||||
SaveWindowSize();
|
||||
|
||||
mLastFocusedWindow = NULL;
|
||||
mIsDeleting = true;
|
||||
|
||||
// Mac: we never quit as the result of a close.
|
||||
|
@ -710,9 +710,6 @@ private:
|
||||
|
||||
bool mLockPlayRegion;
|
||||
|
||||
// See AudacityProject::OnActivate() for an explanation of this.
|
||||
wxWindow *mLastFocusedWindow{};
|
||||
|
||||
std::unique_ptr<ImportXMLTagHandler> mImportXMLTagHandler;
|
||||
|
||||
// Last auto-save file name and path (empty if none)
|
||||
|
@ -1491,11 +1491,19 @@ void ToolManager::DoneDragging()
|
||||
mDidDrag = false;
|
||||
mClicked = false;
|
||||
|
||||
RestoreFocus();
|
||||
}
|
||||
|
||||
bool ToolManager::RestoreFocus()
|
||||
{
|
||||
if (mLastFocus) {
|
||||
auto temp1 = AButton::TemporarilyAllowFocus();
|
||||
auto temp2 = ASlider::TemporarilyAllowFocus();
|
||||
auto temp3 = Meter::TemporarilyAllowFocus();
|
||||
auto parent = mLastFocus->GetParent();
|
||||
mLastFocus->SetFocus();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -71,6 +71,8 @@ class ToolManager final : public wxEvtHandler, public wxEventFilter
|
||||
|
||||
int FilterEvent(wxEvent &event) override;
|
||||
|
||||
bool RestoreFocus();
|
||||
|
||||
private:
|
||||
|
||||
ToolBar *Float( ToolBar *t, wxPoint & pos );
|
||||
|
Loading…
x
Reference in New Issue
Block a user