Re: initial keyboard focus, tabbing and keyboard accelerators [message #41202] |
Tue, 19 October 2004 01:34  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Benjamin Hornberger writes:
> the keyboard accelerators and tab modes for widgets in IDL 6.1 are a
> good thing to make IDL applications more intuitive and effient. However,
> I still see quite a few limitations.
>
> First, does anybody know if I can specify which widget will get the
> initial keyboard focus when a new window is popped up?
Whichever widget you choose to set the INPUT_FOCUS keyword
on with WIDGET_CONTROL. :-)
>
> It would be great if I could open a popup which is supposed to collect
> some info from the user, and right away the text field had the keyboard
> focus. Then I could just type the value and hit "Enter" to close the
> popup (without having to click into the text field with the mouse first).
You mean without having to program anything. Yes, it would
be great. But, unfortunately, it would throw a massive number
of programmers out of work. For now, we must put up with
programming the whole thing itself. It is only a matter
of setting the focus, and doing the right thing when you
get the Enter event in your event handler. But I've written
many widgets that act as you describe.
> More features which seem to be missing or incomplete (compared to what I
> consider "standard" at least for Windows applications):
Oh, dear. Let's not even talk about Windows. It is clear
to me after only a month in Europe that LINIX is talking
over the world. :-)
> 1. When I tab into a text field which already has something written in
> it, I would like the existing text to be highlighted already, so that I
> can just overwrite it.
When you get a keyboard focus event in your text widget (you
set it up to do so, right?), then use the SET_TEXT_SELECT
keyword with WIDGET_CONTROL to select whatever text is there.
If you compile fsc_field.pro you will find an example program
at the bottom. Run that and tab between the three text fields
to see what I mean.
> 3. Similarly, I would like text fields (like cw_field or David's
> fsc_field) where I can have one letter in the label underlined. If "Alt"
> plus that letter are pressed, the keyboard focus should jump into the
> text field, and the existing text should be highlighted. This actually
> applies in a similar fashion to all widgets which have a label, like
> sliders, droplists etc.
With the exception of the underlined letter, I think this functionality
can be implemented now. I agree, an underlined letter would be nice,
and make it in color too, as long as you have the code opened up. :-)
> 4. Currently, with tab mode activated, buttons with a bitmap label
> (rather than a text label) don't show visually if they have the keyboard
> focus (are tabbed onto). Buttons with a text label show a dotted
> rectangle on them if they have the keyboard focus.
Tabs on Windows machines beep their heads off at you. What's up with
that!? Annoying as hell. Had to turn all the sounds off on my computer
to deal with it. Now that I think about it, keep that in.
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http:/www.dfanning.com/
Phone: 970-221-0438, IDL Book Orders: 1-888-461-0155
|
|
|
Re: initial keyboard focus, tabbing and keyboard accelerators [message #41446 is a reply to message #41202] |
Tue, 19 October 2004 12:25   |
Benjamin Hornberger
Messages: 258 Registered: March 2004
|
Senior Member |
|
|
David Fanning wrote:
> Benjamin Hornberger writes:
>
>>1. When I tab into a text field which already has something written in
>> it, I would like the existing text to be highlighted already, so that I
>> can just overwrite it.
>
>
> When you get a keyboard focus event in your text widget (you
> set it up to do so, right?), then use the SET_TEXT_SELECT
> keyword with WIDGET_CONTROL to select whatever text is there.
>
> If you compile fsc_field.pro you will find an example program
> at the bottom. Run that and tab between the three text fields
> to see what I mean.
Actually I ran into some trouble with that today. In a popup window, I
want to give the initial keyboard focus to an fsc_field widget. As David
recommended, to mark the existing text I set up keyboard focus events on
the fsc_field (actually the fsc_field's text field, whose ID I get via
fsc_field_object -> GetTextID()). But then I got an error message from
FSC_Field::TextEvents, because it seems not to be prepared for keyboard
focus events ("type" is not a valid field for keyboard focus event
structures, and FSC_Field::TextEvents uses the event.type field right
away). I got around by inserting
IF tag_names(event, /structure_name) EQ 'WIDGET_KBRD_FOCUS' THEN BEGIN
event.id = self.tlb
return, event
ENDIF
at the beginning of FSC_FIELD::TextEvents. This will redirect the
keyboard focus event to the fsc_field's event handler. Maybe there is a
more elegant solution, but this solved the problem for me without
reading the whole code ;-). David, maybe you want to include something
like that into fsc_field?
>
>
>> 3. Similarly, I would like text fields (like cw_field or David's
>> fsc_field) where I can have one letter in the label underlined. If "Alt"
>> plus that letter are pressed, the keyboard focus should jump into the
>> text field, and the existing text should be highlighted. This actually
>> applies in a similar fashion to all widgets which have a label, like
>> sliders, droplists etc.
>
>
> With the exception of the underlined letter, I think this functionality
> can be implemented now. I agree, an underlined letter would be nice,
> and make it in color too, as long as you have the code opened up. :-)
>
I am not sure how I can implement that currently. widget_control,
/input_focus applies only to buttons, draw and text widgets. How can I
give the keyboard focus to a list, droplist, slider or other widget
besides tabbing onto them?
Thanks for any help or comments,
Benjamin
|
|
|
|