1. #1
    Ext User
    Join Date
    Mar 2007
    Posts
    177
    Vote Rating
    1
    Domitian is on a distinguished road

      0  

    Default KeyListener not registering

    KeyListener not registering


    Hey All, I was wondering if someone could tell me why my key listener isn't working for the dialog I've created. The OK button closes the dialog, but for some reason "ESCAPE" isn't working. Here's the code snippet:

    Code:
    handleFailure:function(o)
    	{
    		getEl('error-dlg-center').dom.innerHTML = o.responseText;
    		if(!dialog)
        	{
        		dialog = new YAHOO.ext.LayoutDialog("error-dlg",{
        				modal:true,
                        width:300,
                        height:150,
                        shadow:true,
                        minWidth:300,
                        minHeight:100,
                        proxyDrag: true
    	    	});
        		
        		dialog.addKeyListener(27, dialog.hide, dialog);
    			dialog.addButton('OK', dialog.hide, dialog);
        	}
        	dialog.show(getEl('status').dom);
        	Frame.updateStatus('Error Loading.', 'done')
    	},

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    The dialog has to have focus for the listener to work. You can also do this by using setDefaultButton
    Code:
    dlg.addKeyListener(27, dlg.hide, dlg);
    dlg.addButton('OK', this.okHandler...);
    dlg.setDefaultButton(dlg.addButton('Close', dlg.hide, dlg));

  3. #3
    Ext User
    Join Date
    Mar 2007
    Posts
    177
    Vote Rating
    1
    Domitian is on a distinguished road

      0  

    Default


    Thanks tryan, that did the trick.

Similar Threads

  1. HelloWorld Dialog KeyListener and IE7 Problem
    By jongohr in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 1 May 2008, 12:30 AM
  2. Registering resized and invalidated listener with laoyout Re
    By wavel in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 5 Mar 2007, 11:27 PM
  3. YUI Help - KeyListener + Event
    By allaboutyui in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 1 Jan 2007, 3:04 PM
  4. KeyListener, Tabpanel and rest of the site
    By wannabe in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 15 Sep 2006, 10:43 AM

Thread Participants: 1