PDA

View Full Version : Popup form (in a window), any way to do control focus after rendering?



darthwes
2 Nov 2010, 9:28 AM
I'm popping a form in a window to allow for populating a data table. Everything is pretty straight forward. What I have done is create an "Add" button on the window to generate a new fieldset in the form. Now all this works fine. What I'm having problems understanding is how do I set the user's focus to the newly added fieldset (and/or the first field in the field set).

I am aware that I can use defaultButton on windows, but it doesn't seem to address this problem because I've already got the window open and I'm dynamically adding fieldsets. Does anyone know of a solution for this?

For completeness, this is how I'm adding the fieldset to the form.


...
//this is the formpanel
//build up var newFieldSet...
this.add(newFieldSet);
if(this.rendered) {
this.doLayout();
}
...

Condor
3 Nov 2010, 5:41 AM
Using the defaultButton is the safest option (it also refocusses after dragging or resizing the window).

But you probably want:

this.defaultButton = <field-to-focus>;
if(this.rendered) {
this.doLayout();
this.focus();
}

darthwes
3 Nov 2010, 12:11 PM
You are the king of all 2.5m-or-greater-wingspan avians!