Hybrid View

  1. #1
    Ext User dotnetCarpenter's Avatar
    Join Date
    Mar 2007
    Location
    Copenhagen, Denmark
    Posts
    271
    Vote Rating
    0
    dotnetCarpenter is on a distinguished road

      0  

    Default addKeyListener to fire click event on button

    addKeyListener to fire click event on button


    I have a button created by Ext.LayoutDialog.addButton method and would like to fire the click event on enter. But I keep hitting the never ending scope problem (in this case I get fn.call is not a function).
    I've tried a dozen ways but instead of pasting all of that I'm just gonna show my most recent attempt.
    Code:
    dialog.addKeyListener(13, btnNext.fireEvent('click'), btnNext);
    the btnNext is define like this:
    Code:
    var btnNext = dialog.addButton(la_next, function(){...
    and the dialog, like this:
    Code:
    var dialog = new Ext.LayoutDialog("wizard-dlg", { 
    	modal: true,
        width:600,
        height:450,
        shadow:true,
    	collapsible: false,
    	fixedcenter: true,
    	resizable: false
    });
    I couldn't find any examples but if you know any - please post!

  2. #2
    Sencha - Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    26,166
    Vote Rating
    82
    jsakalos is a splendid one to behold jsakalos is a splendid one to behold jsakalos is a splendid one to behold jsakalos is a splendid one to behold jsakalos is a splendid one to behold jsakalos is a splendid one to behold jsakalos is a splendid one to behold

      0  

    Default


    Part of your problem can be that you execute the btnNext.fireEvent('click') in the addKeyListener call. Second argument of the addKeyListener is function, you execute the function instead and use return value as second argument.