]> git.saurik.com Git - wxWidgets.git/commitdiff
If a wxPy[Command]Event has been cloned then we need to propogate the
authorRobin Dunn <robin@alldunn.com>
Thu, 31 Jul 2003 19:21:48 +0000 (19:21 +0000)
committerRobin Dunn <robin@alldunn.com>
Thu, 31 Jul 2003 19:21:48 +0000 (19:21 +0000)
Skip value from the original back to the clone after it has been
processed.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22424 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/src/helpers.cpp
wxPython/src/helpers.h

index 6da4eb0423d87a0d05ee9c8990a7662bd85b555b..74e229aa8112d4c94eb50e488ab0e8b84d405fef 100644 (file)
@@ -1306,29 +1306,50 @@ void wxPyCallback::EventThunker(wxEvent& event) {
     PyObject*       result;
     PyObject*       arg;
     PyObject*       tuple;
-
+    bool            checkSkip = FALSE;
 
     wxPyBeginBlockThreads();
     wxString className = event.GetClassInfo()->GetClassName();
 
-    if (className == wxT("wxPyEvent"))
-        arg = ((wxPyEvent*)&event)->GetSelf();
-    else if (className == wxT("wxPyCommandEvent"))
-        arg = ((wxPyCommandEvent*)&event)->GetSelf();
+    // If the event is one of these types then pass the original
+    // event object instead of the one passed to us.
+    if ( className == wxT("wxPyEvent") ) {
+        arg =       ((wxPyEvent*)&event)->GetSelf();
+        checkSkip = ((wxPyEvent*)&event)->GetCloned();
+    }
+    else if ( className == wxT("wxPyCommandEvent") ) {
+        arg =       ((wxPyCommandEvent*)&event)->GetSelf();
+        checkSkip = ((wxPyCommandEvent*)&event)->GetCloned();
+    }
     else {
         arg = wxPyConstructObject((void*)&event, className);
     }
 
+    // Call the event handler, passing the event object
     tuple = PyTuple_New(1);
-    PyTuple_SET_ITEM(tuple, 0, arg);
+    PyTuple_SET_ITEM(tuple, 0, arg);  // steals ref to arg
     result = PyEval_CallObject(func, tuple);
-    Py_DECREF(tuple);
-    if (result) {
-        Py_DECREF(result);
+    if ( result ) {
+        Py_DECREF(result);   // result is ignored, but we still need to decref it
         PyErr_Clear();       // Just in case...
     } else {
         PyErr_Print();
     }
+
+    if ( checkSkip ) {
+        // if the event object was one of our special types and
+        // it had been cloned, then we need to extract the Skipped
+        // value from the original and set it in the clone.
+        result = PyObject_CallMethod(arg, "GetSkipped", "");
+        if ( result ) {
+            event.Skip(PyInt_AsLong(result));
+            Py_DECREF(result);
+        } else {
+            PyErr_Print();
+        }
+    }
+
+    Py_DECREF(tuple);
     wxPyEndBlockThreads();
 }
 
index e3432295a65e0956eaf80ae1be291b419de9014d..4ad5a73ac1a7e0cf0f5c22cce0485090e108d8bd 100644 (file)
@@ -184,6 +184,7 @@ public:
 
     void SetSelf(PyObject* self, bool clone=FALSE);
     PyObject* GetSelf() const;
+    bool GetCloned() const { return m_cloned; }
 
 protected:
     PyObject*   m_self;