Re: draw widget + keyboard events [message #31089] |
Mon, 17 June 2002 11:37 |
Rick Towler
Messages: 821 Registered: August 1998
|
Senior Member |
|
|
"Ken Mankoff" <mankoff@I.HATE.SPAM.cs.colorado.edu> wrote in message
news:Pine.LNX.4.44.0206070852280.17631-100000@snoe.colorado. edu...
>
> On Fri, 7 Jun 2002, Ken Mankoff wrote:
>> I have a draw widget, and I want to be able to respond to keyboard
>> events in the widget. Is this possible? I see a /MOTION_EVENT and
>> /BUTTON_EVENT flag for the draw widget, but no /KEY_EVENT
>
> OK, nevermind... sorry for not checking google first.
> The answer is "no", but you can hack it by hiding a text widget behind
> the draw widget. How to get the location of the mouse at the time of
> the keypress is another issue...
What platform?
If it is windows I have a .dlm that can poll keyboard, mouse and joystick
states. You generally would run it inside of a timer event and it provides
far better response than the text widget trick. Downside is that like the
text widget hack you can only read a single keypress at a time (although you
can simultaneously get keyboard, mouse and joystick states) and it is
windows only.
-Rick
|
|
|
Re: draw widget + keyboard events [message #31119 is a reply to message #31089] |
Wed, 12 June 2002 16:56  |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
On Fri, 07 Jun 2002 07:53:56 -0700, Ken Mankoff wrote:
> On Fri, 7 Jun 2002, Ken Mankoff wrote:
>> I have a draw widget, and I want to be able to respond to keyboard
>> events in the widget. Is this possible? I see a /MOTION_EVENT and
>> /BUTTON_EVENT flag for the draw widget, but no /KEY_EVENT
>
> OK, nevermind... sorry for not checking google first.
>
> The answer is "no", but you can hack it by hiding a text widget behind
> the draw widget. How to get the location of the mouse at the time of the
> keypress is another issue...
>
>
Well, I always set the input focus in the event callback by doing
something like:
widget_control, self.wHid,/INPUT_FOCUS,set_value=['..','..','..'], $
SET_TEXT_SELECT=self.base_pos
where self.wHid is the hidden text widget. This is done preferrably on
every button click of the draw window (motion events don't change input
focus), incoming WIDGET_TRACKING and all hidden key events. You might
just set_value to '', but I've since developed a refinement to the hack
which allows you to detect arrow keypresses too (although not quite as
reliably as for normal keys), which requires more than one line of text.
I've also had success with certain control key combinations. I think
you'll find all this and more in posts of mine on the topic spread over
the last couple of years.
It's ugly, but it works. I've heard whisperings on the grapevine that a
real cross-platform key event mechanism might make it into some future
version of IDL. I would have voted for that over context menus any day
;).
Good luck,
JD
|
|
|
Re: draw widget + keyboard events [message #31162 is a reply to message #31119] |
Fri, 07 June 2002 07:53  |
Ken Mankoff
Messages: 158 Registered: February 2000
|
Senior Member |
|
|
On Fri, 7 Jun 2002, Ken Mankoff wrote:
> I have a draw widget, and I want to be able to respond to keyboard
> events in the widget. Is this possible? I see a /MOTION_EVENT and
> /BUTTON_EVENT flag for the draw widget, but no /KEY_EVENT
OK, nevermind... sorry for not checking google first.
The answer is "no", but you can hack it by hiding a text widget behind
the draw widget. How to get the location of the mouse at the time of
the keypress is another issue...
-k.
|
|
|