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:
		@@ -130,6 +130,7 @@ wxMSW:
 | 
			
		||||
wxX11:
 | 
			
		||||
 | 
			
		||||
- Added mouse wheel support (David Hart)
 | 
			
		||||
- Make Enter key activate the default button (David Hart)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
2.8.4
 | 
			
		||||
 
 | 
			
		||||
@@ -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