keyboard events with WIDGET_DRAW [message #16001] |
Tue, 22 June 1999 00:00  |
D. Mattes
Messages: 14 Registered: May 1999
|
Junior Member |
|
|
hello idl widget gurus:
does anyone know how to capture keyboard events when a draw widget has
focus??? i'd like to be able to use keypresses as shortcuts when someone
is using the mouse inside the draw widget.
thanks for your help!
david mattes
|
|
|
Re: Keyboard events [message #20843 is a reply to message #16001] |
Fri, 28 July 2000 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Doug Reynolds (dsreyn@ll.mit.edu) writes:
> I'm in the process of writing a new application, and several of the likely
> users have requested that I allow various keyboard "shortcuts", as an
> alternative to clicking on various controls with the mouse. For example,
> we will need to define a region in an image that will be zoomed in a
> separate draw window, and it would be nice to be able to use arrow keys
> to position and resize the zoom region.
>
> I've never tried to do this before in IDL (previously I've been content
> to handle mouse events), so I went looking through the manuals to figure
> out how to do it. Unfortunately, the event handling routines seem to be
> limited to mouse and focus events. The closest thing I could find was the
> get_kbrd function; someone here suggested putting a call to get_kbrd in
> the event handling function. However, it would seem that this would cause
> keyboard events to queue up, unprocessed, until the user wiggled the mouse.
> In other words, it doesn't seem to be quite what I need.
>
> Is there something in the documentation that I have overlooked? Any ideas
> would be most appreciated.
As Wesley says in the Princess Bride, "Get used to disappointment."
How come this hasn't made the Top 10 List? I'm putting it
at number 3, right after "Chop IDL Up into Pieces and Charge
Us for Every Bit". :-)
Cheers,
David
P.S. For a clever hack by JD Smith, see this article on my
web page:
http://www.dfanning.com/tips/keyboard_events.html
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: Keyboard events [message #20845 is a reply to message #16001] |
Fri, 28 July 2000 00:00  |
Stephane Beland
Messages: 1 Registered: July 2000
|
Junior Member |
|
|
"Doug Reynolds" <dsreyn@ll.mit.edu> wrote in message
news:tzgg5.127$y4.6066@llslave...
> I'm in the process of writing a new application, and several of the likely
> users have requested that I allow various keyboard "shortcuts", as an
> alternative to clicking on various controls with the mouse. For example,
> we will need to define a region in an image that will be zoomed in a
> separate draw window, and it would be nice to be able to use arrow keys
> to position and resize the zoom region.
>
> I've never tried to do this before in IDL (previously I've been content
> to handle mouse events), so I went looking through the manuals to figure
> out how to do it. Unfortunately, the event handling routines seem to be
> limited to mouse and focus events. The closest thing I could find was the
> get_kbrd function; someone here suggested putting a call to get_kbrd in
> the event handling function. However, it would seem that this would cause
> keyboard events to queue up, unprocessed, until the user wiggled the
mouse.
> In other words, it doesn't seem to be quite what I need.
>
> Is there something in the documentation that I have overlooked? Any ideas
> would be most appreciated.
>
> Doug
I had a similar problem which I solved with a hack. IDL UNFORTUNATLY does
not
pass the keyboard event on a draw window.
I got the idea from a previous posting.
What you do is create a text window behind the draw window and give it the
keyboard
focus. When the arrow keys are pressed, the event is for the text window
and you can
figure out which arrow key was pressed in the event handler.
My application turned out to be a little more complicated than that since on
UNIX (don't know about Windoze)
I wasn't able to get the keyboard events for the cursor keys. I ended up
creating a 3 by 3 text widget and putting
the cursor in the middle. Every time the text cursor moved, i read the new
location and figure out which
arrow key was pressed then move the cursor back in the middle for the next
arrow key hit.
Told you it was a hack.
In the end it works very well.
--
Stephane Beland
Senior Application Programmer
Center for Astrophysics and Space Astronomy
University of Colorado - Boulder
|
|
|