1. #1
    Sencha User silveralecs's Avatar
    Join Date
    Apr 2012
    Posts
    32
    Vote Rating
    1
    silveralecs is on a distinguished road

      0  

    Default Focus on field when clicking a container

    Focus on field when clicking a container


    I want to focus on a field after I clicked a container.

    Firstly, I don't understand why the Ext.container.Container doesn't have an event for click, so I implemented the event by myself:
    Code:
    overPlaceholder.addListener('afterrender', function(){
      overPlaceholder.getEl().dom.addEventListener('click', function(){
        passwordField.fireEvent('focus', passwordField);
      });
    });
    Secondly, I don't get why the password field is not being focused after I click the container.

    Can you help me ?

    Thank you

  2. #2
    Sencha User silveralecs's Avatar
    Join Date
    Apr 2012
    Posts
    32
    Vote Rating
    1
    silveralecs is on a distinguished road

      0  

    Default


    Managed to figure this out by using:

    Code:
    overPlaceholder.addListener('afterrender', function(){
                    overPlaceholder.getEl().dom.addEventListener('click', function(){
                                     passwordField.focus();
                    });
    });
    But still:
    1. Why doesn't Ext.container.Container support the clicking event ?
    2. Why passwordField.triggerEvent('focus'); doesn't work, but passwordField.focus() works ?

  3. #3
    Sencha User Legolas's Avatar
    Join Date
    Apr 2010
    Location
    Brazil/MG
    Posts
    58
    Vote Rating
    3
    Legolas is on a distinguished road

      0  

    Default


    Quote Originally Posted by silveralecs View Post
    Managed to figure this out by using:
    1. Why doesn't Ext.container.Container support the clicking event ?
    silveralecs, I do not know for sure. But I think if the component is an container, so that your items will be Clickable.
    Quote Originally Posted by silveralecs View Post
    Managed to figure this out by using:
    2. Why passwordField.triggerEvent('focus'); doesn't work, but passwordField.focus() works ?
    The main difference between "fireEvent()" and "focus()" are:
    The first method only will fire the event while and the second method will apply the focus in your component.
    I am sorry my english, I am learning yet
    Portuguese blog: http://wessdevel.blogspot.com.br/
    Twitter: @wlegolas

Thread Participants: 1

Tags for this Thread