I have a ListCtrl with a LIST_ITEM_SELECTED and CONTEXT_MENU events
(the latter is not required to reproduce this, but it shows a weird
thing).
In the item selected event (only on the last item, in the attached
example), a CallAfter is issued to a function which call a method of
the main window which opens a custom modal dialog.
The problem is that, after the dialog opens, it's impossible to click
it, move it, or whatever. The main windows is not clickable either,
and there's no feedback that there is a modal dialog like happens
normally.
The bizarre thing is: right clicking the dialog opens the context menu
of the ListCtrl! After dismissing the menu, the dialog comes back to
normal (it does too if you switch to another program and switch back).
This only happens with CallAfter (it's required in my application,
it's actually called from a thread). And it only happens with the
LIST_ITEM_SELECTED event, not with, for example, LEFT_DOWN.
Does anyone have any ideas on what's going on?
Please run the attached example, click the third item, and try to
click the dialog. Then right-click the dialog.
Using wxPython 2.8.8.1 (msw-unicode), Python 2.5.2, Windows XP SP 2.
I have a ListCtrl with a LIST_ITEM_SELECTED and CONTEXT_MENU events
(the latter is not required to reproduce this, but it shows a weird
thing).
In the item selected event (only on the last item, in the attached
example), a CallAfter is issued to a function which call a method of
the main window which opens a custom modal dialog.
The problem is that, after the dialog opens, it's impossible to click
it, move it, or whatever. The main windows is not clickable either,
and there's no feedback that there is a modal dialog like happens
normally.
This is definitely very weird... Rod Sterling weird...
My best guess is that the native listctrl is doing something as part of the events following the selection that captures the mouse, and it is during that time that the CallAfter event is processed and the dialog is shown. So you get into a state that the dialog can't get mouse events because the listctrl has captured it, and the mouse won't be released until the ShowModal exits and control returns into the main loop.
The bizarre thing is: right clicking the dialog opens the context menu
of the ListCtrl! After dismissing the menu, the dialog comes back to
normal (it does too if you switch to another program and switch back).
Showing the popup menu causes the mouse capture to be broken.
This only happens with CallAfter (it's required in my application,
it's actually called from a thread). And it only happens with the
LIST_ITEM_SELECTED event, not with, for example, LEFT_DOWN.
Try this: Instead of having the CallAfter function show the dialog, have it set a short timer (wx.CallLater can help with this) and show the dialog from there. Waiting an extra 100ms won't be noticable to the user, but will probably give the listctrl enough time to finish whatever it is doing.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
This is definitely very weird... Rod Sterling weird...
My best guess is that the native listctrl is doing something as part of the
events following the selection that captures the mouse, and it is during
that time that the CallAfter event is processed and the dialog is shown. So
you get into a state that the dialog can't get mouse events because the
listctrl has captured it, and the mouse won't be released until the
ShowModal exits and control returns into the main loop.
I took a peek at the listctrl code and couldn't find anything
suspicious... though I have very little experience with wx code.
Try this: Instead of having the CallAfter function show the dialog, have it
set a short timer (wx.CallLater can help with this) and show the dialog from
there. Waiting an extra 100ms won't be noticable to the user, but will
probably give the listctrl enough time to finish whatever it is doing.
It works, but it's not very reliable. At 100ms it locks often, at
300ms it's rare. It's good enough for me, for now...
I've just confirmed that it's a wxWidgets issue, by reproducing the
bug with a changed ListCtrl sample (and I've just remembered how I
hate C++ ). Should I submit a bug in the tracker or ask the wx
list?
Thanks,
Conrado
···
On Mon, Sep 15, 2008 at 19:29, Robin Dunn <robin@alldunn.com> wrote:
I've just confirmed that it's a wxWidgets issue, by reproducing the
bug with a changed ListCtrl sample (and I've just remembered how I
hate C++ ). Should I submit a bug in the tracker or ask the wx
list?
Yes, please do. Also include the patch for the listctrl sample that shows how to reproduce the problem.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!