Re: Keyboard input from widgets [message #29341] |
Wed, 13 February 2002 10:17 |
Rick Towler
Messages: 821 Registered: August 1998
|
Senior Member |
|
|
David's link is a great place to start and probably is the best general
solution for grabbing keyboard input in widgets.
The get_kbrd() function will probably not work. The problem with it is that
it requires the IDL command prompt to have focus and your application and
IDLDE can't share the focus which leads to a very awkward interface.
I tried writing some functions in C to read the keyboard but ran into the
focus problem again. (I think that RSI was using the same windows functions
to read keyboard input in their get_kbrd() function as I was in mine.) I'm
sure there is a way to trap keystrokes before they get to the OS but the
only method I know of to do this went out with Borland Turbo C 2.0 and DOS.
What I ended up with is a windows .dlm to read the accelerator keys (shift,
alt, ctrl, etc.) and to get input from the gameport. It is a start. I hope
to add extended mouse support soon. But as fun and exciting as this .dlm
is, it isn't portable.
David also mentioned that from within IDL there isn't a way to manipulate
anything more than the cursor icon. I'm sure some functions to manipulate
mouse parameters (acceleration, speed) would be fairly easy in C but I think
that would depend on your OS too.
-Rick
"Oleg Kornilov" <to_oleg@mail.ru> wrote in message
news:820c611d.0202130822.7806e3dc@posting.google.com...
> Hi,
> I have draw widget and I use mouse events in it (cursor moving and
> buttons). I need to know also what key on keyboard was pressed (for
> example, for precision moving of mouse cursor). Problem that
> base_widget does't generate events for keyboard and draw_widget
> switches into stdin (IDL command line). Probably I can use timer
> events and get_kbrd() to check keyboard buffer.
> Is there another way ?
> Thank you.
|
|
|
Re: Keyboard input from widgets [message #29342 is a reply to message #29341] |
Wed, 13 February 2002 09:22  |
Pavel A. Romashkin
Messages: 531 Registered: November 2000
|
Senior Member |
|
|
David Fanning wrote:
>
> The other is that there is no way AFAIK to programmatically
> place the cursor at a particular location in a draw
> widget.
Uh, I am sure one could easily communicate directly with his mouse's USB
driver to position the cursor. All it'd take is a DLM, right?
Cheers,
Pavel
|
|
|
Re: Keyboard input from widgets [message #29345 is a reply to message #29342] |
Wed, 13 February 2002 08:37  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Oleg Kornilov (to_oleg@mail.ru) writes:
> I have draw widget and I use mouse events in it (cursor moving and
> buttons). I need to know also what key on keyboard was pressed (for
> example, for precision moving of mouse cursor). Problem that
> base_widget does't generate events for keyboard and draw_widget
> switches into stdin (IDL command line). Probably I can use timer
> events and get_kbrd() to check keyboard buffer.
> Is there another way ?
There are two problems with this design that come
immediately to mind. One, there is no way to get
keyboard input into a widget program without performing
a severe hack. See, for example:
http://www.dfanning.com/widget_tips/keyboard_events.html
The other is that there is no way AFAIK to programmatically
place the cursor at a particular location in a draw
widget.
Other than that, this ought to be a piece of cake. :-)
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
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
|
|
|