How to set focus on text fields?

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

How to set focus on text fields?

Carl Gundel
I generate some pages that have a text field using code like this:

html form:
     [html text: self text , '?'.
     html textInputWithCallback: [:value | self acceptedValue: value].
     html submitButtonWithAction:
       [self accepted: true.
       self triggerEvent: #inputAccepted with: self]
      text: 'Accept'.
     html div]

When the page loads I need to be able to automatically set the input focus
to the field so the user can just start typing, and then when Enter is
pressed the submit button should get triggered.  Is there a Seaside
'convenience way' to do this, or if not how would I set about doing this in
Seaside 'the hard way'?  ;-)

Also, is there any way to generate a page such that the view scrolls down to
a particular WAComponent when the page loads?

Thanks,

-Carl Gundel, author of Liberty BASIC
http://www.libertybasic.com


_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: How to set focus on text fields?

Michel Bany-3
Try this, with the classic api :

    html autofocus: [
        html textInputWithCallback: [:value | self acceptedValue: value] ]

There is also #autofocus:withCursorAt:

With the canvas api :
 
    html textInput setFocus; etc.

HTH
Michel.

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside