Fix focus handling logic in generic wxListCtrl.

Don't override SetFocus() to set the focus to the main window, this isn't
enough as we can be given the focus by the underlying toolkit itself, without
our SetFocus() being called -- this happened in wxGTK when focus was changed
from the keyboard using TAB and in this case it didn't get to the main window
but remaining on the wxListCtrl itself meaning that keyboard input wasn't
processed at all.

Use wxNavigationEnabled<> now to ensure that OnSetFocus() and related methods
do the right thing instead now.

Also get rid of OnSetFocus() in wxListHeaderWindow, it's better to override
AcceptsFocus() to return false to avoid getting focus in the first place.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71039 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-03-29 00:10:53 +00:00
parent 34326da778
commit 22930be86c
3 changed files with 5 additions and 18 deletions

View File

@@ -934,7 +934,6 @@ void wxListLineData::ReverseHighlight( void )
BEGIN_EVENT_TABLE(wxListHeaderWindow,wxWindow)
EVT_PAINT (wxListHeaderWindow::OnPaint)
EVT_MOUSE_EVENTS (wxListHeaderWindow::OnMouse)
EVT_SET_FOCUS (wxListHeaderWindow::OnSetFocus)
END_EVENT_TABLE()
void wxListHeaderWindow::Init()
@@ -1341,12 +1340,6 @@ void wxListHeaderWindow::OnMouse( wxMouseEvent &event )
}
}
void wxListHeaderWindow::OnSetFocus( wxFocusEvent &WXUNUSED(event) )
{
m_owner->SetFocus();
m_owner->Update();
}
bool wxListHeaderWindow::SendListEvent(wxEventType type, const wxPoint& pos)
{
wxWindow *parent = GetParent();
@@ -5154,14 +5147,6 @@ void wxGenericListCtrl::DoScreenToClient( int *x, int *y ) const
wxListCtrlBase::DoScreenToClient(x, y);
}
void wxGenericListCtrl::SetFocus()
{
// The test in window.cpp fails as we are a composite
// window, so it checks against "this", but not m_mainWin.
if ( DoFindFocus() != this )
m_mainWin->SetFocus();
}
wxSize wxGenericListCtrl::DoGetBestClientSize() const
{
// Something is better than nothing even if this is completely arbitrary.