Allow user code to override key events in generic wxListCtrl.
The changes of r58323 ("Restore keyboard navi") fixed the handling of cursor keys in the generic wxListCtrl implementation but at the price of not sending keyboard events for the cursor keys to wxListCtrl itself any more. This made it impossible to override their handling in user code, something that used to work in previous wx versions and still works in wxMSW. Revert the changes of this revision now and fix the original code by simply disabling the handling of the cursor keys in wxScrollHelperBase using a newly added DisableKeyboardScrolling() method. This ensures that the keyboard events for cursor keys are not used to scroll the window when they are forwarded to wxListCtrl from wxListMainWindow. The fix is conceptually ugly as it would be better to avoid the need for such ad hoc functions as DisableKeyboardScrolling() but it is very simple and there just doesn't seem to be any sane way to do it otherwise with wxScrollHelperBase. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64877 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -2753,21 +2753,11 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
|
||||
parent->GetEventHandler()->ProcessEvent( le );
|
||||
}
|
||||
|
||||
if ( (event.GetKeyCode() != WXK_UP) &&
|
||||
(event.GetKeyCode() != WXK_DOWN) &&
|
||||
(event.GetKeyCode() != WXK_RIGHT) &&
|
||||
(event.GetKeyCode() != WXK_LEFT) &&
|
||||
(event.GetKeyCode() != WXK_PAGEUP) &&
|
||||
(event.GetKeyCode() != WXK_PAGEDOWN) &&
|
||||
(event.GetKeyCode() != WXK_END) &&
|
||||
(event.GetKeyCode() != WXK_HOME) )
|
||||
{
|
||||
// propagate the char event upwards
|
||||
wxKeyEvent ke(event);
|
||||
ke.SetEventObject( parent );
|
||||
if (parent->GetEventHandler()->ProcessEvent( ke ))
|
||||
return;
|
||||
}
|
||||
// propagate the char event upwards
|
||||
wxKeyEvent ke(event);
|
||||
ke.SetEventObject( parent );
|
||||
if (parent->GetEventHandler()->ProcessEvent( ke ))
|
||||
return;
|
||||
|
||||
if ( HandleAsNavigationKey(event) )
|
||||
return;
|
||||
@@ -4359,6 +4349,11 @@ bool wxGenericListCtrl::Create(wxWindow *parent,
|
||||
|
||||
SetTargetWindow( m_mainWin );
|
||||
|
||||
// We use the cursor keys for moving the selection, not scrolling, so call
|
||||
// this method to ensure wxScrollHelperEvtHandler doesn't catch all
|
||||
// keyboard events forwarded to us from wxListMainWindow.
|
||||
DisableKeyboardScrolling();
|
||||
|
||||
wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
|
||||
sizer->Add( m_mainWin, 1, wxGROW );
|
||||
SetSizer( sizer );
|
||||
|
Reference in New Issue
Block a user