PDA

View Full Version : Set focus on inputtext by default


productengine
10-15-2003, 12:01 AM
Hi!
Is there any ability to set focus on inputtext by default. For example I have form that contains only inputtext control and one button, and I want to set focus on inputtext after form was invoked.

antun
10-15-2003, 11:04 AM
The answer is there there should be, but it doesn't work completely. You can use inputtext.setAttribute('focus', true), but that doesn't appear to work from an oninit method, it does work if called from a method or event handler that's attached to some user action (onclick, oninit etc):


<canvas debug="true">
<debug x="200" />

<simplelayout axis="y" spacing="10" />
<inputtext name="foo">
<method name="makeFocused">
debug.write( 'makeFocused called' );
this.setAttribute( 'focus', true );
</method>
</inputtext>

<button>
<method event="onclick">
foo.makeFocused();
</method>
</button>
</canvas>


I tried putting an oninit method in the canvas, as well as a timer delegate, which called the makeFocused() method a couple of seconds after initing, but neither of those worked. I filed a bug (# 2385).

You might be able to get this to work somehow - if the user mouses over a part of the app or something.

-Antun