1. #1
    Sencha User
    Join Date
    Feb 2011
    Posts
    9
    Vote Rating
    0
    alessalessio is on a distinguished road

      0  

    Question Set Focus on a TextField within a FormPanel

    Set Focus on a TextField within a FormPanel


    I actually decides to open a thread about this argument, since i experienced it is not working as i imagined,and read many post about this but found no clear solution.

    The problem statement is quite simple:

    Have a form panel and Fields within it, how can i set the focus onto a field?

    The next two simple code does not do the job:

    1)
    TextField tf = new TextField<String>();
    Button button = new Button("focus on textfield");

    button.addSelectionListener(new SelectionListener<ButtonEvent>(){
    @Override
    public void componentSelected(ButtonEvent ce) {
    tf.setFocus();
    }
    });


    2)
    TextField tf = new TextField<String>();
    Window window = new Window();
    window.add(tf);

    window.setFocusWidget(tf);



    What am i doing wrong?

  2. #2
    Sencha User
    Join Date
    Apr 2011
    Posts
    40
    Vote Rating
    1
    liondev is on a distinguished road

      0  

    Default


    if you textfield is into a panel just:

    component.focus();

    if your component is on a Window use

    setFocusWidget(component);

  3. #3
    Sencha User
    Join Date
    Feb 2011
    Posts
    9
    Vote Rating
    0
    alessalessio is on a distinguished road

      0  

    Default


    liondev, thanks for the reply,
    but if you notice the piece of code i wrote,
    i used both commands, and it doesn't work! That's the problem




    Quote Originally Posted by liondev View Post
    if you textfield is into a panel just:

    component.focus();

    if your component is on a Window use

    setFocusWidget(component);

  4. #4
    Sencha User
    Join Date
    Apr 2011
    Posts
    40
    Vote Rating
    1
    liondev is on a distinguished road

      0  

    Default


    try: make your own class extends from Window or ContenPanel

    in the constructor add the components u will need.
    then focus it


    that works for me

Similar Threads

  1. Replies: 8
    Last Post: 10 Jun 2012, 9:55 PM
  2. Replies: 0
    Last Post: 23 May 2010, 10:47 AM
  3. Textfield sometimes not getting focus
    By yanfa01 in forum Ext GWT: Discussion
    Replies: 2
    Last Post: 6 May 2010, 12:23 AM
  4. textfield focus
    By archmisha in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 25 Feb 2009, 10:54 AM
  5. How to properly focus TextField in FormPanel
    By c.mallwitz in forum Ext GWT: Help & Discussion (1.x)
    Replies: 0
    Last Post: 27 Nov 2008, 1:16 PM

Thread Participants: 1

Tags for this Thread