]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/event.cpp
fix to previous patch: don't crash when saving in 16bpp
[wxWidgets.git] / src / common / event.cpp
index 55484498bb2926adc534c3a046e795e75e228ead..bab410244b6e3799296b279321e431cab39fec1b 100644 (file)
@@ -44,6 +44,7 @@
         #include "wx/control.h"
         #include "wx/utils.h"
         #include "wx/dc.h"
+        #include "wx/textctrl.h"
     #endif // wxUSE_GUI
 #endif
 
@@ -380,8 +381,16 @@ wxEvent::wxEvent(const wxEvent &src)
  *
  */
 
+#ifdef __VISUALC__
+    // 'this' : used in base member initializer list (for m_commandString)
+    #pragma warning(disable:4355)
+#endif
+
 wxCommandEvent::wxCommandEvent(wxEventType commandType, int theId)
               : wxEvent(theId, commandType)
+#if WXWIN_COMPATIBILITY_2_4
+              , m_commandString(this)
+#endif
 {
     m_clientData = (char *) NULL;
     m_clientObject = (wxClientData *) NULL;
@@ -393,6 +402,26 @@ wxCommandEvent::wxCommandEvent(wxEventType commandType, int theId)
     m_propagationLevel = wxEVENT_PROPAGATE_MAX;
 }
 
+#ifdef __VISUALC__
+    #pragma warning(default:4355)
+#endif
+
+wxString wxCommandEvent::GetString() const
+{
+    if(m_eventType != wxEVT_COMMAND_TEXT_UPDATED || !m_eventObject)
+        return m_cmdString;
+    else
+    {
+#if wxUSE_TEXTCTRL
+        wxTextCtrl *txt = wxDynamicCast(m_eventObject, wxTextCtrl);
+        if(txt)
+            return txt->GetValue();
+        else
+#endif // wxUSE_TEXTCTRL
+            return m_cmdString;
+    }
+}
+
 /*
  * UI update events
  */
@@ -1345,7 +1374,7 @@ bool wxEvtHandler::SearchDynamicEventTable( wxEvent& event )
         wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)node->GetData();
 #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
 
-        if ((event.m_eventType == entry->m_eventType) && (entry->m_fn != 0))
+        if ((event.GetEventType() == entry->m_eventType) && (entry->m_fn != 0))
         {
             wxEvtHandler *handler =
 #if !WXWIN_COMPATIBILITY_EVENT_TYPES