Re: Mouse and keyboard events in a draw widget [message #10679 is a reply to message #10544] |
Thu, 18 December 1997 00:00  |
David Foster
Messages: 341 Registered: January 1996
|
Senior Member |
|
|
James Albert wrote:
>
> I have a draw widget that I do a bunch of image/coastline plotting in.
> I am currently currently working on a tool that will let the user
> measure a target in the image, in pixels. The tool has a vernier which
> should open and close (imagine a C-clamp) and the tool should rotate.
> I have all the code in place with one exception; no user interface to
> the actions. I think I have two choices;
> 1) an additional base with four buttons on it:open,close,rotate
> clockwise, rotate counter clockwise.
> This should be relatively easy to implement, but it's not my first
> choice
> 2) using the cursor keys to hook the actions. Unfortunately, I can't
> find any information on getting keyboard events in DrawWidgets -
> get_kbrd() just doesn't work until the widget is destroyed
If you want to use method #2 then JD Smith's suggestion (on David's
IDL Tips page) would work very well.
One thing I have done in the past, when I wanted to have "buttons"
that allowed more than one action, was to create small draw widgets
and use XYOUTS to place a label in them, and then basically use
these draw widgets as buttons. This way, you can use the different
mouse buttons to do various things; LEFT click could be "rotate
clockwise", and RIGHT click could be "rotate counter-clockwise".
Of course, you can use your original draw widget for this as well,
as David Fanning suggests; it all depends what you want your
interface to look like. I usually like to have buttons (or "draw
buttons" in this case), or *something* there that gives the user a
clue what they have to do when they are looking at the interface
(means fewer times I have to explain to people how the damn thing
works!).
I have an example program using this technique if you're interested.
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 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
|
|
|