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

      0  

    Question How can I do to fire a button click event?

    How can I do to fire a button click event?


    Hi everyone!!!

    I'm trying to fire a button click event, but I'm afraid to do something bad, because my listener never catches the event (I never see the alert ).

    This is what I wrote:

    Code:
    	    final Button myButton= new Button();
    	    myButton.setSize("90px", "45px");
    	    myButton.setText("PRESS ME");
    	    myButton.addSelectionListener(new SelectionListener<ButtonEvent>() {
    	    	public void componentSelected(ButtonEvent ce) {
    	    	}
    	    	public void handleEvent(ButtonEvent e) {
    	    		
    	    		MessageBox.alert("", "HELLO", null);
    	    	}
    	    });
    
    	    EventType et = new EventType(Event.ONCLICK);
    	    myButton.fireEvent(et);
    Could you please give a clue to me?

    Thanks a lot!!!

    Regards,Luca

  2. #2
    Ext GWT Premium Member takayser's Avatar
    Join Date
    Oct 2008
    Location
    Lucerne, Switzerland
    Posts
    188
    Vote Rating
    0
    takayser is an unknown quantity at this point

      -1  

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

      0  

    Default


    Thank you very much takayser

  4. #4
    Sencha User
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    You never ever want to do this. Its one of the worst practices you can do. You should create a method that the listener calls and you can also call manually.

  5. #5
    Sencha User
    Join Date
    Feb 2011
    Posts
    15
    Vote Rating
    0
    Luca_80 is on a distinguished road

      0  

    Default


    Yes I've already done so, but I was curious how dispatching events

  6. #6
    Sencha User
    Join Date
    Jan 2011
    Posts
    26
    Vote Rating
    2
    emkramer is on a distinguished road

      1  

    Default Programmatically Clicking a Button

    Programmatically Clicking a Button


    Instead of providing a helpful response, all you do is redirect this hapless user to a place to buy premium support???!!!


    Quote Originally Posted by takayser View Post

  7. #7
    Ext GWT Premium Member takayser's Avatar
    Join Date
    Oct 2008
    Location
    Lucerne, Switzerland
    Posts
    188
    Vote Rating
    0
    takayser is an unknown quantity at this point

      0  

    Default


    this "only premium can see that" is a new "feature".

    Quote Originally Posted by takayser View Post
    just let the button fire a Select event is not really programmatically click a button. Extend Button with following:

    Code:
    public void click() {
          ((ButtonElement) getFocusEl().dom.cast()).click();
       }

  8. #8
    Sencha User
    Join Date
    Jan 2011
    Posts
    26
    Vote Rating
    2
    emkramer is on a distinguished road

      0  

    Default


    ah, I see

  9. #9
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    82
    Vote Rating
    1
    RobertGary1 is on a distinguished road

      1  

    Default


    If you only call the button's handler then you miss the styling update that an actual button press would provide.

  10. #10
    Sencha Premium Member
    Join Date
    Jan 2008
    Location
    San Francisco Bay, CA
    Posts
    42
    Vote Rating
    1
    rgralhoz is on a distinguished road

      0  

    Default QA automation

    QA automation


    Also calling a click event would be useful for QA (GUI test automation). Instead of trying to understand the developer code to find which function is the actual handler, the GUI tester could have a generic "button.doClick()" call to simulate a user click with UX and behavior integrated.

    It could be accomplished by

    Code:
    button.fireEvent('click', button);

Similar Threads

  1. fire click event on an element
    By flamant in forum Ext 3.x: Help & Discussion
    Replies: 5
    Last Post: 7 Nov 2010, 8:04 AM
  2. Ext.Button fire more than once when continually click
    By yuncong8 in forum Ext 2.x: Help & Discussion
    Replies: 6
    Last Post: 28 Nov 2008, 1:37 AM
  3. Cannot fire click event on Ext.Button
    By fermo111 in forum Ext 2.x: Help & Discussion
    Replies: 9
    Last Post: 11 Dec 2007, 6:24 PM
  4. how to fire button click
    By runnersixty in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 3 Nov 2007, 7:59 AM
  5. addKeyListener to fire click event on button
    By dotnetCarpenter in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 16 May 2007, 10:14 AM

Thread Participants: 5