+ 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)
+ self.RefreshItem(self.curRow)
+
+ def _SelectIndex(self, row):
+ listlen = self.GetItemCount()
+ if row < 0 and not listlen:
+ return
+ if row > (listlen-1):
+ row = listlen -1
+
+ self.SetItemState(self.curRow, ~wx.LIST_STATE_SELECTED,
+ wx.LIST_STATE_SELECTED)
+ self.EnsureVisible(row)
+ self.SetItemState(row, wx.LIST_STATE_SELECTED,
+ wx.LIST_STATE_SELECTED)