Re: processing keyboard events in X [message #9756 is a reply to message #9694] |
Wed, 13 August 1997 00:00   |
Aviv Gladman
Messages: 8 Registered: August 1997
|
Junior Member |
|
|
A surprisingly effective and elegant "hack". The hidden text object works
perfectly in SunOS 5. I assume the basis for this is the fact that motion
events are passed through the text widget to the draw widget event
handler, so that motion events can still be processed even if the focus
is on the text widget. Haven't tried this on Win95, and I will admit to
some curiosity, since Windows and X handle events in fundamentally
different ways. Are we exploiting the properties of the X window manager,
or of IDL?
Aviv S. Gladman
----
Imaging Research, Sunnybrook Health Science Centre, Toronto, Canada
On Mon, 11 Aug 1997, J.D. Smith wrote:
> Aviv Gladman wrote:
>>
>> Writing a GUI in IDL 5 (SunOS 5) and would like to be able to process
>> keyboard interrupts from any window (as opposed to from stdin). Such an
>> operation would be trivial in C/C++, but I can't seem to find any way of
>> getting IDL to recognize that a key has been pressed while the mouse
>> focus is on a draw widget, for example.Being unable to create widget
>> hotkeys is, IMO, a ridiculous limitation, so I'm sure there must be a way
>> to do it. Any ideas? Please respond via e-mail, if possible (mail reader
>> is *very* slow).
>>
>> Thanks,
>>
>> Aviv S. Gladman, MASc
>
> As David points out, this functionality is not built in. But if you're
> willing to settle for a hack, I have come up with one. The mouse focus
> and keyboard focus are independent, which you can use to your
> advantage. It's very simple, really. All you need to do is hide a
> widget_text widget with all_events set *underneath* your draw widget,
> and ensure its input focus is set when appropriate in the event
> handler. I have simply set focus every time through, but a better
> technique would do so only when entering the window, or when a button on
> the draw window is clicked (motion events do not remove the input
> focus), etc. I've tested this on Linux IDL v5.0, but no guarantees are
> made for other platforms (it *should* work on any of them though).
> [snip]
|
|
|