Fix generic wxDataViewCtrl Enter handling to conform to Windows UI.
Spacebar is used to activate columns (e.g. toggle a checkbox). Enter activates the item, i.e. sends wxEVT_COMMAND_ITEM_ACTIVATED. If that event isn't handled, Enter acts the same as Space. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68992 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -3325,10 +3325,26 @@ void wxDataViewMainWindow::OnChar( wxKeyEvent &event )
|
|||||||
switch ( event.GetKeyCode() )
|
switch ( event.GetKeyCode() )
|
||||||
{
|
{
|
||||||
case WXK_RETURN:
|
case WXK_RETURN:
|
||||||
case WXK_SPACE:
|
|
||||||
{
|
{
|
||||||
|
// Enter activates the item, i.e. sends wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED to
|
||||||
|
// it. Only if that event is not handled do we activate column renderer (which
|
||||||
|
// is normally done by Space).
|
||||||
|
|
||||||
const wxDataViewItem item = GetItemByRow(m_currentRow);
|
const wxDataViewItem item = GetItemByRow(m_currentRow);
|
||||||
|
|
||||||
|
wxDataViewEvent le(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED,
|
||||||
|
parent->GetId());
|
||||||
|
le.SetItem(item);
|
||||||
|
le.SetEventObject(parent);
|
||||||
|
le.SetModel(GetModel());
|
||||||
|
|
||||||
|
if ( parent->GetEventHandler()->ProcessEvent(le) )
|
||||||
|
break;
|
||||||
|
// else: fall through to WXK_SPACE handling
|
||||||
|
}
|
||||||
|
|
||||||
|
case WXK_SPACE:
|
||||||
|
{
|
||||||
// Activate the first activatable column if there is any:
|
// Activate the first activatable column if there is any:
|
||||||
wxDataViewColumn *activatableCol = NULL;
|
wxDataViewColumn *activatableCol = NULL;
|
||||||
|
|
||||||
@@ -3345,27 +3361,16 @@ void wxDataViewMainWindow::OnChar( wxKeyEvent &event )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool activated = false;
|
|
||||||
|
|
||||||
if ( activatableCol )
|
if ( activatableCol )
|
||||||
{
|
{
|
||||||
|
const wxDataViewItem item = GetItemByRow(m_currentRow);
|
||||||
|
|
||||||
const unsigned colIdx = activatableCol->GetModelColumn();
|
const unsigned colIdx = activatableCol->GetModelColumn();
|
||||||
const wxRect cell_rect = GetOwner()->GetItemRect(item, activatableCol);
|
const wxRect cell_rect = GetOwner()->GetItemRect(item, activatableCol);
|
||||||
|
|
||||||
wxDataViewRenderer *cell = activatableCol->GetRenderer();
|
wxDataViewRenderer *cell = activatableCol->GetRenderer();
|
||||||
cell->PrepareForItem(GetModel(), item, colIdx);
|
cell->PrepareForItem(GetModel(), item, colIdx);
|
||||||
activated = cell->WXOnActivate(cell_rect, GetModel(), item, colIdx);
|
cell->WXOnActivate(cell_rect, GetModel(), item, colIdx);
|
||||||
}
|
|
||||||
|
|
||||||
if ( !activated )
|
|
||||||
{
|
|
||||||
wxDataViewEvent le(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED,
|
|
||||||
parent->GetId());
|
|
||||||
le.SetItem(item);
|
|
||||||
le.SetEventObject(parent);
|
|
||||||
le.SetModel(GetModel());
|
|
||||||
|
|
||||||
parent->GetEventHandler()->ProcessEvent(le);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user