- if self.IsVirtual():
- # replace by whather you use to populate the virtual ListCtrl
- # data source
- self.SetVirtualData(self.curRow, self.curCol, text)
- else:
- self.SetStringItem(self.curRow, self.curCol, text)
+ self.SetFocus()
+
+ # post wxEVT_COMMAND_LIST_END_LABEL_EDIT
+ # Event can be vetoed. It doesn't has SetEditCanceled(), what would
+ # require passing extra argument to CloseEditor()
+ evt = wx.ListEvent(wx.wxEVT_COMMAND_LIST_END_LABEL_EDIT, self.GetId())
+ evt.m_itemIndex = self.curRow
+ evt.m_col = self.curCol
+ item = self.GetItem(self.curRow, self.curCol)
+ evt.m_item.SetId(item.GetId())
+ evt.m_item.SetColumn(item.GetColumn())
+ evt.m_item.SetData(item.GetData())
+ evt.m_item.SetText(text) #should be empty string if editor was canceled
+ ret = self.GetEventHandler().ProcessEvent(evt)
+ if not ret or evt.IsAllowed():
+ if self.IsVirtual():
+ # replace by whather you use to populate the virtual ListCtrl
+ # data source
+ self.SetVirtualData(self.curRow, self.curCol, text)
+ else:
+ self.SetStringItem(self.curRow, self.curCol, text)