]> git.saurik.com Git - wxWidgets.git/commitdiff
wx.lib.mixins.listctrl.TextEditMixin: Fixed the double END_LABEL_EDIT
authorRobin Dunn <robin@alldunn.com>
Thu, 25 May 2006 15:41:53 +0000 (15:41 +0000)
committerRobin Dunn <robin@alldunn.com>
Thu, 25 May 2006 15:41:53 +0000 (15:41 +0000)
event problem in TextEditMixin by checking if the editor was already
hidden before continuing with the CloseEditor method.  Also added code
to OpenEditor to send the BEGIN_LABEL_EDIT event and to not allow the
opening of the editor to continue if the event handler doesn't allow
it.

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

wxPython/wx/lib/mixins/listctrl.py

index 71504759da85b31de40c07ee4fa43e6fb9d62e87..c649396f72634c5daf8385634260f2ca79021e9e 100644 (file)
@@ -522,6 +522,19 @@ class TextEditMixin:
     def OpenEditor(self, col, row):
         ''' Opens an editor at the current position. '''
 
+        # give the derived class a chance to Allow/Veto this edit.
+        evt = wx.ListEvent(wx.wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, self.GetId())
+        evt.m_itemIndex = row
+        evt.m_col = col
+        item = self.GetItem(row, col)
+        evt.m_item.SetId(item.GetId()) 
+        evt.m_item.SetColumn(item.GetColumn()) 
+        evt.m_item.SetData(item.GetData()) 
+        evt.m_item.SetText(item.GetText()) 
+        ret = self.GetEventHandler().ProcessEvent(evt)
+        if ret and not evt.IsAllowed():
+            return   # user code doesn't allow the edit.
+
         if self.GetColumn(col).m_format != self.col_style:
             self.make_editor(self.GetColumn(col).m_format)
     
@@ -574,6 +587,8 @@ class TextEditMixin:
     # it is binded to wx.EVT_KILL_FOCUS. Can it be avoided? (MW)
     def CloseEditor(self, evt=None):
         ''' Close the editor and save the new value to the ListCtrl. '''
+        if not self.editor.IsShown():
+            return
         text = self.editor.GetValue()
         self.editor.Hide()
         self.SetFocus()