Re: How to get the position of mouse [message #32739 is a reply to message #32737] |
Tue, 05 November 2002 05:27  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
lily_zhang (fengliza@sina.com) writes:
> I display an image on the screen first, and then intend to get the
> coordinate of mouse when I depress the left button of it. Would you
> tell me how to realize it?
In a regular graphics window, you would do something like
this:
Window
TV, image
Cursor, x, y, /Down
IF !Mouse EQ 1 THEN Print, 'You pressed LEFT button.'
But, typically, if you are asking for user input, you
will be doing this in a draw widget window, in which case
you will turn button events on for the window, and then
process the event in an event handler like this:
possibleEvents = ['DOWN', 'UP', 'MOTION']
whichButton = ['NONE', 'LEFT', 'MIDDLE', 'NONE', 'RIGHT']
thisEvent = possibleEvents[event.type]
buttonPressed = whichButton[event.press]
IF thisEvent EQ 'DOWN' THEN Print, 'You pressed the ' + $
buttonPressed + ' button down.'
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|