From: Robin Dunn Date: Fri, 26 Jul 2002 01:51:50 +0000 (+0000) Subject: Show how to prevent deselection of specific items X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/9c2abc2c9ab4be591396495777b09bd115c83172 Show how to prevent deselection of specific items git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16281 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/wxPython/demo/wxListCtrl.py b/wxPython/demo/wxListCtrl.py index 8bb12dfb76..d1b9cf245f 100644 --- a/wxPython/demo/wxListCtrl.py +++ b/wxPython/demo/wxListCtrl.py @@ -163,6 +163,7 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin): self.currentItem = 0 EVT_SIZE(self, self.OnSize) EVT_LIST_ITEM_SELECTED(self, tID, self.OnItemSelected) + EVT_LIST_ITEM_DESELECTED(self, tID, self.OnItemDeselected) EVT_LIST_ITEM_ACTIVATED(self, tID, self.OnItemActivated) EVT_LIST_DELETE_ITEM(self, tID, self.OnItemDelete) EVT_LIST_COL_CLICK(self, tID, self.OnColClick) @@ -217,6 +218,13 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin): # this does self.list.SetItemState(10, 0, wxLIST_STATE_SELECTED) + # Show how to reselect something we don't want deselected + def OnItemDeselected(self, evt): + item = evt.GetItem() + if evt.m_itemIndex == 11: + wxCallAfter(self.list.SetItemState, 11, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED) + + def OnItemActivated(self, event): self.currentItem = event.m_itemIndex self.log.WriteText("OnItemActivated: %s\n" % self.list.GetItemText(self.currentItem))