Generate key events in generic wxDataViewCtrl implementation.

Forward wxEVT_CHAR events from wxDataViewMainWindow to the parent window so
that they could be processed at wxDataViewCtrl level.

Call DisableKeyboardScrolling() to ensure that cursor movement keys are not
always eaten by the parent window but can be used for the navigation in the
control if they're not processed by user.

Add a test keyboard handler to the dataview sample to check that handling keys
in wxDataViewCtrl does work.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64957 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-07-14 11:12:03 +00:00
parent e0ff229573
commit 63ced01b22
2 changed files with 38 additions and 6 deletions

View File

@@ -3281,7 +3281,15 @@ void wxDataViewMainWindow::DestroyTree()
void wxDataViewMainWindow::OnChar( wxKeyEvent &event )
{
if ( GetParent()->HandleAsNavigationKey(event) )
wxWindow * const parent = GetParent();
// propagate the char event upwards
wxKeyEvent eventForParent(event);
eventForParent.SetEventObject(parent);
if ( parent->ProcessWindowEvent(eventForParent) )
return;
if ( parent->HandleAsNavigationKey(event) )
return;
// no item -> nothing to do
@@ -3299,7 +3307,6 @@ void wxDataViewMainWindow::OnChar( wxKeyEvent &event )
{
case WXK_RETURN:
{
wxWindow *parent = GetParent();
wxDataViewEvent le(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED,
parent->GetId());
le.SetItem( GetItemByRow(m_currentRow) );
@@ -3861,6 +3868,11 @@ bool wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id,
m_clientArea = new wxDataViewMainWindow( this, wxID_ANY );
// 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();
if (HasFlag(wxDV_NO_HEADER))
m_headerArea = NULL;
else