[wxpython-users] CallAfter, ListCtrl, and Modal dialog issue
Robin Dunn
robin at alldunn.com
Mon Sep 15 15:29:26 PDT 2008
Conrado PLG wrote:
> Hello,
>
> I'm having a very bizarre issue with my app.
>
> 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!
More information about the wxpython-users
mailing list