I'm writing an app where the user can select an item from a ListCtrl, edit some data, and save it.
However if the users changes the ListCtrl selection before saving, the application should prompt the user to save it (Yes/No/Cancel).
If the users presses cancel, the selection should be set back to the item the user was editing.
This works perfectly when using the arrow keys to change selection, but when I use the mouse, the whole event seems to be called twice. (once initially, and once again after I cancel and set selection back to the original item)
This sounds complicated, but I attached a little test app showcasing this behavior.
Is this a bug?
If not, does anyone know how I can avoid this problem when the selection is changed using the mouse?
Using wxPython 2.5.1.5 on MSW (Win2000) and Python 2.3.3
Oh, and yes I'm using a ListView, but trust me a ListCtrl behaves exactly the same way.
I'm writing an app where the user can select an item from a ListCtrl, edit some data, and save it.
However if the users changes the ListCtrl selection before saving, the application should prompt the user to save it (Yes/No/Cancel).
If the users presses cancel, the selection should be set back to the item the user was editing.
This works perfectly when using the arrow keys to change selection, but when I use the mouse, the whole event seems to be called twice. (once initially, and once again after I cancel and set selection back to the original item)
This sounds complicated, but I attached a little test app showcasing this behavior.
Is this a bug?
Probably.
If not, does anyone know how I can avoid this problem when the selection is changed using the mouse?
For some reason Windows is sending us another set of item focused and item selected messages. Probably there is some interaction between the messagebox and the fact that there is a spare left up event waiting to happen or something like that. Or perhaps the fact that focus changes when the dialog is dismissed.
You might try using a custom dialog or some other way to decide to reset the selection, or perhaps using wx.CallAfter to reset the selection later after the current series of events have completed.
Using wxPython 2.5.1.5 on MSW (Win2000) and Python 2.3.3
Hmmm... Interestingly it doesn't happen on XP when themese are active (so a newer version of the common controls DLL is used) but it does happen when themes are disabled (older version of common controls).
Oh, and yes I'm using a ListView, but trust me a ListCtrl behaves exactly the same way.
ListView is just a simple derivation of ListCtrl, so they should definitly (mis-)behave in the same ways.
ยทยทยท
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!