X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a7b09001af8d72c2c151ac01597965616b13b14c..a28ae4096bb21302ce2ad59ca846ce590f8488bf:/src/common/wincmn.cpp diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 2801de986d..24158367eb 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -633,6 +633,41 @@ wxEvtHandler *wxWindowBase::PopEventHandler(bool deleteHandler) return handlerA; } +bool wxWindowBase::RemoveEventHandler(wxEvtHandler *handler) +{ + wxCHECK_MSG( handler, FALSE, _T("RemoveEventHandler(NULL) called") ); + + wxEvtHandler *handlerPrev = NULL, + *handlerCur = GetEventHandler(); + while ( handlerCur ) + { + wxEvtHandler *handlerNext = handlerCur->GetNextHandler(); + + if ( handlerCur == handler ) + { + if ( handlerPrev ) + { + handlerPrev->SetNextHandler(handlerNext); + } + else + { + SetEventHandler(handlerNext); + } + + handler->SetNextHandler(NULL); + + return TRUE; + } + + handlerPrev = handlerCur; + handlerCur = handlerNext; + } + + wxFAIL_MSG( _T("where has the event handler gone?") ); + + return FALSE; +} + // ---------------------------------------------------------------------------- // cursors, fonts &c // ----------------------------------------------------------------------------