From aadb49f66526e64bd89505cb13bd692d1c045453 Mon Sep 17 00:00:00 2001 From: David Elliott Date: Mon, 3 Sep 2007 17:17:35 +0000 Subject: [PATCH] Implement wxButton::SetDefault to call SetDefaultItem on the top-level window. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@48529 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/cocoa/button.h | 1 + src/cocoa/button.mm | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/wx/cocoa/button.h b/include/wx/cocoa/button.h index aefc9d1369..c126130aac 100644 --- a/include/wx/cocoa/button.h +++ b/include/wx/cocoa/button.h @@ -59,6 +59,7 @@ public: wxString GetLabel() const; void SetLabel(const wxString& label); wxSize DoGetBestSize() const; + virtual void SetDefault(); }; #endif diff --git a/src/cocoa/button.mm b/src/cocoa/button.mm index 4a14d6ba2d..45726b8205 100644 --- a/src/cocoa/button.mm +++ b/src/cocoa/button.mm @@ -15,6 +15,7 @@ #ifndef WX_PRECOMP #include "wx/log.h" + #include "wx/toplevel.h" #endif #include "wx/stockitem.h" @@ -105,6 +106,16 @@ wxSize wxButton::DoGetBestSize() const return size; } +void wxButton::SetDefault() +{ + wxTopLevelWindow * const + tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow); + + wxCHECK_RET( tlw != NULL, _T("button without top level window?") ); + + tlw->SetDefaultItem(this); +} + static NSRect MakeNSButtonDefaultRect() { // create at (10.0,10.0) with size 20.0x20.0 (just bogus values)