comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » processing mouse dbl-clicks in IDL?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
processing mouse dbl-clicks in IDL? [message #8702] Fri, 18 April 1997 00:00 Go to next message
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
Hello,

I was wondering if anyone had code or hints on how to process *double*
clicks on a mouse button within an IDL event handler? How would you wait
to check for the same event (a particular mouse button click) to reoccur
within a (user/default) specified time interval?

I looked in the IDL FAQ and various links off of it but didn't find
anything.

Any help/hints appreciated.

Paul van Delst
Re: processing mouse dbl-clicks in IDL? [message #8703 is a reply to message #8702] Fri, 18 April 1997 00:00 Go to previous messageGo to next message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Paul van Delst <paulv@airs2.ssec.wisc.edu> writes:

> I was wondering if anyone had code or hints on how to process *double*
> clicks on a mouse button within an IDL event handler? How would you wait
> to check for the same event (a particular mouse button click) to reoccur
> within a (user/default) specified time interval?
>
> I looked in the IDL FAQ and various links off of it but didn't find
> anything.

Well, here is a piece of code that can reliably detect a double
click on a BUTTON widget, at least on my Mac and Windows NT machines.
I wrote this off the top of my head. I haven't tried to put this
into a real piece of code, so I don't know if it will be generally
useful. (My personal feeling is that I would test any code with
this kind of button stategy VERY carefully before I showed it to
anyone important!)

Here is how it works. The first button click sets a "first" flag
and sends a TIMER event to the button. If a SECOND button click event
gets to the event handler BEFORE the TIMER event does, then this
is a DOUBLE CLICK event! A timer delay of 0.1 second works
perfectly on my Mac. I need a delay of 0.2 seconds on
my (much faster) Windows NT machine.

Let me know how this works in a real piece of code. :-)

Cheers!

David

************************************************************ ***
PRO MOUSE_EVENT,event
WIDGET_CONTROL, event.top, /DESTROY
END


PRO DOUBLE_MOUSE_CLICK, event
WIDGET_CONTROL, event.top, GET_UVALUE=info, /NO_COPY
thisEvent = TAG_NAMES(event, /Structure)

; Double click event.

IF (thisEvent EQ 'WIDGET_BUTTON') AND (info.first EQ 1) THEN BEGIN
Print, 'Hooray, DOUBLE click!'
info.first = 0
WIDGET_CONTROL, event.top, SET_UVALUE=info, /NO_COPY
RETURN
ENDIF

; Initial click event.

IF (thisEvent EQ 'WIDGET_BUTTON') AND (info.first EQ 0) THEN BEGIN
info.first = 1
WIDGET_CONTROL, event.id, Timer=info.delay
ENDIF

; Single click event.

IF (thisEvent EQ 'WIDGET_TIMER') AND (info.first EQ 1) THEN BEGIN
Print, 'No, that was a SINGLE click!'
info.first = 0
ENDIF

WIDGET_CONTROL, event.top, SET_UVALUE=info, /NO_COPY
END


PRO MOUSE, delay
IF N_PARAMS() EQ 0 THEN delay = 0.1
info = {first:0, delay:delay}
tlb = WIDGET_BASE(COLUMN=1)
button = WIDGET_BUTTON(tlb, Value='Double Click Me...', $
EVENT_PRO='DOUBLE_MOUSE_CLICK')
quit = WIDGET_BUTTON(tlb, Value='Quit')
WIDGET_CONTROL, tlb, /REALIZE, SET_UVALUE=info, /NO_COPY
XMANAGER, 'mouse', tlb
END
************************************************************ ***

-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
2642 Bradbury Court, Fort Collins, CO 80521
Phone: 970-221-0438 Fax: 970-221-4762
E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
-----------------------------------------------------------
Re: processing mouse dbl-clicks in IDL? [message #8781 is a reply to message #8702] Mon, 21 April 1997 00:00 Go to previous message
David Foster is currently offline  David Foster
Messages: 341
Registered: January 1996
Senior Member
Paul van Delst wrote:
>
> Hello,
>
> I was wondering if anyone had code or hints on how to process *double*
> clicks on a mouse button within an IDL event handler? How would you wait
> to check for the same event (a particular mouse button click) to reoccur
> within a (user/default) specified time interval?

It would really depend upon what kind of widget you wanted to process
the double-clicks for. To me the most useful applications of this
would be with draw and list widgets. For list widgets, note that the
event returned contains a field called CLICKS (1 or 2) that specifies
whether the event was generated by one or two clicks. For draw
widgets, you can probably modify David Fanning's advice for button
widgets.

Dave
--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2200
La Jolla, CA 92037
[ UCSD Mail Code 0949 ]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
Re: processing mouse dbl-clicks in IDL? [message #8789 is a reply to message #8702] Mon, 21 April 1997 00:00 Go to previous message
J.D. Smith is currently offline  J.D. Smith
Messages: 214
Registered: August 1996
Senior Member
David Fanning wrote:

> Well, here is a piece of code that can reliably detect a double
> click on a BUTTON widget, at least on my Mac and Windows NT machines.
> I wrote this off the top of my head. I haven't tried to put this
> into a real piece of code, so I don't know if it will be generally
> useful. (My personal feeling is that I would test any code with
> this kind of button stategy VERY carefully before I showed it to
> anyone important!)
>
> Here is how it works. The first button click sets a "first" flag
> and sends a TIMER event to the button. If a SECOND button click event
> gets to the event handler BEFORE the TIMER event does, then this
> is a DOUBLE CLICK event! A timer delay of 0.1 second works
> perfectly on my Mac. I need a delay of 0.2 seconds on
> my (much faster) Windows NT machine.
>
> Let me know how this works in a real piece of code. :-)

I'd like also to point out that widget_list returns double clicks in its
events... so if you only need to detect double clicks on a list of text
items, there's no work to do. Also, it's machine/OS independent.

JD
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: START a FREE Online Business TODAY
Next Topic: Object Oriented Programming Book Recommendation

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:43:53 PDT 2025

Total time taken to generate the page: 0.00627 seconds