wxListBox mouse events

Hi all,

The wxListBox event handlers (EVT_LISTBOX and EVT_LISTBOX_DCLICK) are
giving me a headache.

I've got two distinct functions associated with the two handlers - each
one opens a different wxDialog.
  1) Single click calls Function-A, and opens Dialog-A
  2) Double click calls Function-B, and opens Dialog-B

The first works fine.

The second triggers both an EVT_LISTBOX AND an EVT_LISTBOX_DCLICK, but
only Function-A and Dialog-A run, which I'd like to avoid.

(Note: If I disable the EVT_LISTBOX handler temporarily, the
EVT_LISTBOX_DCLICK opens Dialog-B, as desired, so the code in Function-B
seems to be okay).

The demo exhibits similar behavior, but the d-click function runs right
after the select function.

Function-A gets the correct EVENT_TYPE (single-click select), so there's
no way to tell if a double-click is following.

Any ideas on how to determine if a double-click was issued so I can
by-pass opening Dialog-A?

Or any ideas on how to achieve two distinct Dialogs from a wxListBox
using the mouse?

I'm on WinXP, with Python 2.2.2 and wxPython 2.4.0.7.

(also, I've tried a Right_Up event to separate the two functions, but
the hit_test is not implemented according to the archives, for wxListBox
- is there any chance that will be available in the near future?)

Thanks in advance for any suggestions,
Dan Cherry

Dan Cherry wrote:

Hi all,

The wxListBox event handlers (EVT_LISTBOX and EVT_LISTBOX_DCLICK) are
giving me a headache.

I've got two distinct functions associated with the two handlers - each
one opens a different wxDialog. 1) Single click calls Function-A, and opens Dialog-A
  2) Double click calls Function-B, and opens Dialog-B

The first works fine.

The second triggers both an EVT_LISTBOX AND an EVT_LISTBOX_DCLICK, but
only Function-A and Dialog-A run, which I'd like to avoid.

(Note: If I disable the EVT_LISTBOX handler temporarily, the
EVT_LISTBOX_DCLICK opens Dialog-B, as desired, so the code in Function-B
seems to be okay).

The demo exhibits similar behavior, but the d-click function runs right
after the select function.

Function-A gets the correct EVENT_TYPE (single-click select), so there's
no way to tell if a double-click is following.

Any ideas on how to determine if a double-click was issued so I can
by-pass opening Dialog-A?

The second click hasn't happened yet when the EVT_LISTBOX handler is called so there is no way to tell without reading the user's mind if the second click is going to happen. Instead you need to wait a bit to give the user the chance to click the second time. So don't invoke Dialog-A from the EVT_LISTBOX handler but just start a timer. If you get the EVT_LISTBOX_DCLICK then stop the timer and show Dialog-B, otherwise when the timer expires show DIalog-A.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin, the wxTimer worked like a charm - thanks very much. Anyone
needing to differentiate CLICK from DOUBLE-CLICK would do well to use
the approach.

Python is my first go around with open source - I'm IMPRESSED with the
quick response, not just to my inquiry, but to everyone's issues. I'm
sold!

Ps/ I had already tried wxReadUsersMind(self), but since I was doing my
own testing, the only response I could return was "NONE"! <wink:joke>

Again, thanks,
Dan Cherry

Dan Cherry wrote:
> Hi all,
>
> The wxListBox event handlers (EVT_LISTBOX and EVT_LISTBOX_DCLICK)

are

> giving me a headache.
>

Robin replied:

The second click hasn't happened yet when the EVT_LISTBOX handler is
called so there is no way to tell without reading the user's mind if

the

second click is going to happen. Instead you need to wait a bit to

give

the user the chance to click the second time. So don't invoke

Dialog-A

from the EVT_LISTBOX handler but just start a timer. If you get the
EVT_LISTBOX_DCLICK then stop the timer and show Dialog-B, otherwise

when

the timer expires show DIalog-A.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail:

wxPython-users-help@lists.wxwindows.org