From 67eb8143206e3f8d64d2ad7e63290a95cf3f1e84 Mon Sep 17 00:00:00 2001 From: JDV Date: Tue, 12 Jul 2016 12:31:35 -0600 Subject: [PATCH] Fixes focus not being set on gamelist after tab change Once a tab is selected the focus can be set directly from the page changed event. However once the tab was shown, the first tab order control element was given the focus by default. This was fixed by delaying the action and setting the focus after the default focus had been assigned. --- .../DolphinWX/NetPlay/NetPlaySetupFrame.cpp | 20 +++++++++++++++++++ .../DolphinWX/NetPlay/NetPlaySetupFrame.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.cpp b/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.cpp index 60cb5b437a..a1126429d6 100644 --- a/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.cpp +++ b/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.cpp @@ -239,6 +239,9 @@ NetPlaySetupFrame::NetPlaySetupFrame(wxWindow* const parent, const CGameListCtrl panel->SetSizerAndFit(main_szr); + // Handle focus on tab changes + panel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, &NetPlaySetupFrame::OnTabChanged, this); + // wxBoxSizer* const diag_szr = new wxBoxSizer(wxVERTICAL); // diag_szr->Add(panel, 1, wxEXPAND); // SetSizerAndFit(diag_szr); @@ -529,6 +532,23 @@ void NetPlaySetupFrame::OnKeyDown(wxKeyEvent& event) } } +void NetPlaySetupFrame::OnTabChanged(wxCommandEvent& event) +{ + // Propagate event + event.Skip(); + + // Delaying action so the first tab order element doesn't override the focus + m_notebook->Bind(wxEVT_IDLE, &NetPlaySetupFrame::OnAfterTabChange, this); +} + +void NetPlaySetupFrame::OnAfterTabChange(wxIdleEvent&) +{ + // Unbinding so we don't hog the idle event + m_notebook->Unbind(wxEVT_IDLE, &NetPlaySetupFrame::OnAfterTabChange, this); + + DispatchFocus(); +} + void NetPlaySetupFrame::DispatchFocus() { int current_tab = m_notebook->GetSelection(); diff --git a/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.h b/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.h index 24acc21b79..87fc1468a9 100644 --- a/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.h +++ b/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.h @@ -38,6 +38,8 @@ private: void OnResetTraversal(wxCommandEvent& event); void OnTraversalListenPortChanged(wxCommandEvent& event); void OnKeyDown(wxKeyEvent& event); + void OnTabChanged(wxCommandEvent& event); + void OnAfterTabChange(wxIdleEvent& event); void DispatchFocus(); void MakeNetPlayDiag(int port, const std::string& game, bool is_hosting);