]> git.saurik.com Git - wxWidgets.git/commitdiff
make Enter/Return activate the default button (second version of patch 1696563)
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 9 Apr 2007 21:28:27 +0000 (21:28 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 9 Apr 2007 21:28:27 +0000 (21:28 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45365 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
src/univ/winuniv.cpp

index e212d89871edbd7a6372e2cdf2ed24a4b548b3b0..5fa6910dc9b5de59f24bb4e97fc8b166da4d8f47 100644 (file)
@@ -130,6 +130,7 @@ wxMSW:
 wxX11:
 
 - Added mouse wheel support (David Hart)
+- Make Enter key activate the default button (David Hart)
 
 
 2.8.4
index 75f8f3bc74e9c40e0c0dbd54fbe411c353ca6b40..c5f8c6e654a13f70c2c5b8418092081ea3efc321 100644 (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();
 }