From f919acdc410dc1fed5c8b56c10d0f2bc869b103b Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Mon, 21 May 2007 12:45:15 +0000 Subject: [PATCH] event handlers get deallocated automatically with their object git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@46141 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/mac/carbon/private/mactext.h | 4 ---- src/mac/carbon/textctrl.cpp | 10 +++++----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/include/wx/mac/carbon/private/mactext.h b/include/wx/mac/carbon/private/mactext.h index c61119e3d4..ab6259e872 100644 --- a/include/wx/mac/carbon/private/mactext.h +++ b/include/wx/mac/carbon/private/mactext.h @@ -102,10 +102,6 @@ protected : // contains the tag for the content (is different for password and non-password controls) OSType m_valueTag ; - - // as the selection tag only works correctly when the control has the focus we have to mirror the - // intended value - EventHandlerRef m_focusHandlerRef ; public : ControlEditTextSelectionRec m_selection ; }; diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index fd154aae35..14062be614 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -261,7 +261,6 @@ public : protected : HIViewRef m_scrollView ; HIViewRef m_textView ; - EventHandlerRef m_textEventHandlerRef ; }; #endif @@ -1383,14 +1382,13 @@ bool wxMacUnicodeTextControl::Create( wxTextCtrl *wxPeer, InstallControlEventHandler( m_controlRef , GetwxMacUnicodeTextControlEventHandlerUPP(), GetEventTypeCount(unicodeTextControlEventList), unicodeTextControlEventList, this, - &m_focusHandlerRef); + NULL); return true; } wxMacUnicodeTextControl::~wxMacUnicodeTextControl() { - ::RemoveEventHandler( m_focusHandlerRef ); } void wxMacUnicodeTextControl::VisibilityChanged(bool shown) @@ -3073,12 +3071,11 @@ wxMacMLTEHIViewControl::wxMacMLTEHIViewControl( wxTextCtrl *wxPeer, InstallControlEventHandler( m_textView , GetwxMacTextControlEventHandlerUPP(), GetEventTypeCount(eventList), eventList, this, - &m_textEventHandlerRef); + NULL); } wxMacMLTEHIViewControl::~wxMacMLTEHIViewControl() { - ::RemoveEventHandler( m_textEventHandlerRef ) ; } OSStatus wxMacMLTEHIViewControl::SetFocus( ControlFocusPart focusPart ) @@ -3089,6 +3086,9 @@ OSStatus wxMacMLTEHIViewControl::SetFocus( ControlFocusPart focusPart ) bool wxMacMLTEHIViewControl::HasFocus() const { ControlRef control ; + if ( GetUserFocusWindow() == NULL ) + return false; + GetKeyboardFocus( GetUserFocusWindow() , &control ) ; return control == m_textView ; }