From 789367e10d91dff77ed0069c4f5079eb7a00db09 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 16 Jul 2006 19:50:48 +0000 Subject: [PATCH] unset the button as temporary default item when it's destroyed (closes bug 1354875) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40135 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/containr.h | 10 ++++++++++ include/wx/window.h | 3 +++ src/msw/button.cpp | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/include/wx/containr.h b/include/wx/containr.h index cd79e5dd5b..34823cfab3 100644 --- a/include/wx/containr.h +++ b/include/wx/containr.h @@ -56,6 +56,10 @@ public: // soon after a call to SetTmpDefaultItem(window) void SetTmpDefaultItem(wxWindow *win) { m_winTmpDefault = win; } + // return the temporary default item, can be NULL + wxWindow *GetTmpDefaultItem() const { return m_winTmpDefault; } + + // the methods to be called from the window event handlers void HandleOnNavigationKey(wxNavigationKeyEvent& event); void HandleOnFocus(wxFocusEvent& event); @@ -114,6 +118,7 @@ public: \ virtual wxWindow *GetDefaultItem() const; \ virtual wxWindow *SetDefaultItem(wxWindow *child); \ virtual void SetTmpDefaultItem(wxWindow *win); \ + virtual wxWindow *GetTmpDefaultItem() const; \ virtual bool AcceptsFocus() const; \ \ protected: \ @@ -142,6 +147,11 @@ wxWindow *classname::GetDefaultItem() const \ return m_container.GetDefaultItem(); \ } \ \ +wxWindow *classname::GetTmpDefaultItem() const \ +{ \ + return m_container.GetTmpDefaultItem(); \ +} \ + \ void classname::OnNavigationKey( wxNavigationKeyEvent& event ) \ { \ m_container.HandleOnNavigationKey(event); \ diff --git a/include/wx/window.h b/include/wx/window.h index 2462fb0d27..9ac9397953 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -528,6 +528,9 @@ public: // set this child as temporary default virtual void SetTmpDefaultItem(wxWindow * WXUNUSED(win)) { } + // return the temporary default item, can be NULL + virtual wxWindow *GetTmpDefaultItem() const { return NULL; } + // navigates in the specified direction by sending a wxNavigationKeyEvent virtual bool Navigate(int flags = wxNavigationKeyEvent::IsForward); diff --git a/src/msw/button.cpp b/src/msw/button.cpp index afb5670992..08361d58b6 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -197,6 +197,11 @@ bool wxButton::Create(wxWindow *parent, wxButton::~wxButton() { + wxWindow *parent = GetParent(); + if ( parent && parent->GetTmpDefaultItem() == this ) + { + UnsetTmpDefault(); + } } // ---------------------------------------------------------------------------- -- 2.45.2