make Enter/Return activate the default button (second version of patch 1696563)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45365 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-04-09 21:28:27 +00:00
parent 63ab3daed9
commit 28117f2426
2 changed files with 20 additions and 0 deletions

View File

@@ -1412,6 +1412,25 @@ void wxWindow::OnChar(wxKeyEvent& event)
}
}
// if Return was pressed, see if there's a default button to activate
if ( !event.HasModifiers() && event.GetKeyCode() == WXK_RETURN )
{
wxTopLevelWindow *
tlw = wxDynamicCast(wxTopLevelWindow *, wxGetTopLevelParent());
if ( tlw )
{
wxButton *btn = wxDynamicCast(wxButton *, tlw->GetDefaultItem());
if ( btn )
{
wxCommandEvent evt(wxEVT_COMMAND_BUTTON_CLICKED, btn->GetId());
evt.SetEventObject(btn);
btn->Command(evt);
return;
}
}
}
event.Skip();
}