diff --git a/interface/wx/listctrl.h b/interface/wx/listctrl.h index c6252bca22..5b50f98537 100644 --- a/interface/wx/listctrl.h +++ b/interface/wx/listctrl.h @@ -1085,7 +1085,7 @@ protected: @event{EVT_LIST_ITEM_RIGHT_CLICK(id, func)} The right mouse button has been clicked on an item. @event{EVT_LIST_KEY_DOWN(id, func)} - A key has been pressed. + A key has been pressed. GetIndex() may be -1 if no item is selected. @event{EVT_LIST_INSERT_ITEM(id, func)} An item has been inserted. @event{EVT_LIST_COL_CLICK(id, func)} diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 008ee79078..4ce0960f73 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -2682,6 +2682,16 @@ void wxListMainWindow::OnKeyDown( wxKeyEvent &event ) if (parent->GetEventHandler()->ProcessEvent( ke )) return; + // send a list event + wxListEvent le( wxEVT_COMMAND_LIST_KEY_DOWN, parent->GetId() ); + le.m_itemIndex = m_current; + if (HasCurrent()) + GetLine(m_current)->GetItem( 0, le.m_item ); + le.m_code = event.GetKeyCode(); + le.SetEventObject( parent ); + if (parent->GetEventHandler()->ProcessEvent( le )) + return; + event.Skip(); } @@ -2701,17 +2711,6 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) { wxWindow *parent = GetParent(); - // send a list_key event up - if ( HasCurrent() ) - { - wxListEvent le( wxEVT_COMMAND_LIST_KEY_DOWN, GetParent()->GetId() ); - le.m_itemIndex = m_current; - GetLine(m_current)->GetItem( 0, le.m_item ); - le.m_code = event.GetKeyCode(); - le.SetEventObject( parent ); - parent->GetEventHandler()->ProcessEvent( le ); - } - // propagate the char event upwards wxKeyEvent ke(event); ke.SetEventObject( parent ); diff --git a/tests/controls/listbasetest.cpp b/tests/controls/listbasetest.cpp index 75e2f56a09..8876612b49 100644 --- a/tests/controls/listbasetest.cpp +++ b/tests/controls/listbasetest.cpp @@ -228,7 +228,7 @@ void ListBaseTestCase::ItemClick() void ListBaseTestCase::KeyDown() { -#if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__) +#if wxUSE_UIACTIONSIMULATOR wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), wxTestableFrame); @@ -239,8 +239,6 @@ void ListBaseTestCase::KeyDown() wxUIActionSimulator sim; list->SetFocus(); - wxYield(); - sim.Text("aAbB"); wxYield();