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:
@@ -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();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user