PDA

View Full Version : CURSOR under Windows XP



rcarne1
10-17-2007, 11:15 AM
I am trying to write a simple procedure that records pixel position to a file based upon clicking a mouse button on a displayed image. I have done this before under VMS and UNIX. I now am on a XP Dell using a 2-button + wheel mouse which seems to function like a 3-buttom mouse such that the left button returns a 1 and the right button a 4. The abbreviated code is:


image_display, im,0,0, Title=ff, window=0, /device ;ff= image

while !err lt 4 do begin ; check for right button

cursor, x,y, /device, wait=1
printf,1, x,y

endwhile

My problem is that this code produces duplicate pairs of coordinates as if I had used WAIT = 2 (change). Values of wait from 1 to 4 have no effect. It is easy enough to work around. Have I misunderstood something or is this a XP/Dell quirk?

Bob Carney
Oceanography
LSU

totallyunimodular
10-18-2007, 11:58 AM
Bob, I see the same behavior (replicate x,y coords returned) on Linux and Solaris. I think the issue is that with Wait=1 the entire time the mouse button is being depressed and raised the event handler returns the coordinates. In fact, on Linux and Solaris the return value to CURSOR is not only duplicated, but is returned more like 5-10 times. I have found that Wait=3 works well for grabbing mouse positions. Additionally, I use !Mouse.button rather than !Err, just to have more clear code, given that other events can change the Err structure.

Hope this helps