Following Ted Bracht's book - how do I make first Team field have focus?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Following Ted Bracht's book - how do I make first Team field have focus?

Tim M
In Ted's book it says that by moving the name field to be the first in the
dialog, its the one that gets focus when the dialog is opened.

In D6 I don't find this true, nothing has focus when I open the dialog, however
when I tab the first field gets focus. Is there any way to get the first
field to have focus on open (or is this some code change I have to make?)

Tim


pax
Reply | Threaded
Open this post in threaded view
|

Re: Following Ted Bracht's book - how do I make first Team field have focus?

pax
Tim,

implement #onViewOpened to handle setting focus to the first field.

MyDialog>>onViewOpened

aField setFocus


aField is actually a presenter that was setup in the #createComponents
method. The presenter can be any type of Presenter or any of the
subclasses from ValuePresenter such as Text, Number, Date, Time,
Boolean etc.

This will ensure that when the dialog box opens, the event #onViewOpend
executes a message send to the correct field and gives it focus. Take a
look at Presenter>>setFocus for additional details.

onViewOpened can also be used to perform other types of initialization
for dropDownBoxes or other components embedded withing the dialog.

Pax


Reply | Threaded
Open this post in threaded view
|

Re: Following Ted Bracht's book - how do I make first Team field have focus?

Chris Uppal-3
In reply to this post by Tim M
Tim,

> In D6 I don't find this true, nothing has focus when I open the dialog,
> however when I tab the first field gets focus.

It works for me in D6 (just like D5).  This is implemented by the method
Shell>>setInitialFocus, perhaps you have overriden that or somehow prevented it
from being called.

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: Following Ted Bracht's book - how do I make first Team field have focus?

Tim M
Hi Chris,

>> In D6 I don't find this true, nothing has focus when I open the
>> dialog, however when I tab the first field gets focus.

You are correct - when I saw the implentation it made me realise that I had
inadvertantly ended up with my OKCancel reference view as the first control
and the initial tab that method does was setting focus to ok cancel.

Thanks for piping up that it should work.

Tim