I think this is MSW only. It’s with wx version 2.6.3.2 (possibly there
since 2.5) and can be demonstrated by adding the following code to
ListCtrl demo - after line 233 (modified demo files are also attached)
# unconditionally change selection from 2 to 4
if self.currentItem == 2:
self.log.WriteText("OnItem 2 Selected: Veto'd selection\n")
self.list.SetItemState(2, 0, wx.LIST_STATE_SELECTED)
wx.CallAfter(self.list.SetItemState, 4,
wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)
# conditionally change selection from 6 to 8
if self.currentItem == 6:
msgbox = wx.MessageDialog(self, 'Select Item 8
instead?’,‘Message’, wx.YES_NO)
if msgbox.ShowModal() == wx.ID_YES:
self.log.WriteText("OnItem 6 Selected: Veto'd
selection\n")
self.list.SetItemState(6 , 0, wx.LIST_STATE_SELECTED)
wx.CallAfter(self.list.SetItemState, 8 ,
wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)
which results in:
OnItemSelected: 2, Billy Joel, The River Of Dreams, Rock
OnItem 2 Selected: Veto’d selection
OnItemDeselected: 2
OnItemSelected: 4, Billy Joel, Famous Last Words, Rock
OnItemDeselected: 4 <== Selected item is
immediately deselected
OnItemSelected: 6, Blue Man Group, Klein Mandelbrot, New Age
OnItem 6 Selected: Veto’d selection
OnItemDeselected: 6
OnItemSelected: 8, Blue Man Group, Drumbone, New Age
OnItemSelected: 6, Blue Man Group, Klein
Mandelbrot, New Age <== Deselected item is re-selected
OnItem 6 Selected: Veto’d selection <==
which brings up the dialog again
OnItemDeselected: 6
Adding the same code to ListCtrl_virtual (change all occurrences of
“self.list” to “self”), the unconditional change works OK but there is
the same problem after the conditional dialog.
Should these be reported back to wxWidgets (if they are reproducible)?
ListCtrl_virtual.py (4.2 KB)
ListCtrl.py (18.9 KB)
···
–
Regards,
David Hughes