Re: Problems using CURSOR [message #5502 is a reply to message #5501] |
Wed, 17 January 1996 00:00   |
Ken Knighton
Messages: 44 Registered: May 1995
|
Member |
|
|
hahn@hrz.th-darmstadt.de (Norbert Hahn) wrote:
> Hi,
>
> My IDL program generates output on a terminal (either X Windows System
> or MS Windows) and wants to return 4 coordinate pairs the users
> selects. However, the following program waits only once for input and
> returns 4 time the same coordinates.
snip, snip
>
> for i=0,3 do begin
> cursor, isx, isy, wait=3
> xin(i) = isx
> yin(i) = isy
> print, isx, isy
> endfor
> end
>
> What is wrong ?
The WAIT keyword to the cursor procedure causes the cursor procedure to
wait until a mouse button is pressed or to return immediately if the
mouse button is already pressed. Using wait=3 has the same meaning
as just /WAIT. I suspect that you have confused the WAIT keyword
with the Wait argument to the cursor function. See the documentation.
What is happening with your program is that your mouse finger is too
slow. When you click the mouse, your program polls the state of the
mouse several times while the button is still down and completes the
loop. What you really want is for CURSOR to wait until a button
transition occurs.
You could have supplied the wait argument (not keyword) by:
cursor, isx, isy, 3
This would have caused CURSOR to return when a mouse button was depressed.
Alternately, (and better for readability) you could have written:
cursor, isx, isy, /DOWN
NOTE: Using X-Windows over a network is slow enough that this problem may
only occur intermittently and produce a real bothersome and hard to notice
and locate feature in your code.
I hope this helps.
Ken Knighton
Fusion Division
General Atomics
San Diego, CA
|
|
|