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.
This commit is contained in:
JDV authored and Aestek committed 2016-07-23 20:58:51 +02:00
1 parent 2ba4b22e88
commit 67eb814320
2 files changed
+22

No files matched your search

@@ -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();
@@ -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);