Results 1 to 4 of 4

Thread: MVC Special Key Listener

  1. #1
    Sencha User
    Join Date
    May 2011
    Posts
    39
    Vote Rating
    0
      0  

    Default Answered: MVC Special Key Listener

    How do you listen for a special key using a controller in MVC architecture?

    For example, if I have a form, how would I make something like this work:

    Code:
    init: function() {
            	this.control({         
    			'form': {
    				specialkey: this.key
    			}
    		});
    	},
      
    	key: function() {
    		console.log('hello');
    	}
    Thanks!

  2. The form panel itself doesn't have a specialkey event that you can listen to. But, the form fields that you'd put into a form panel often times do. So, you could listen to say all of the textfields or all of the combobox's specialkey events. Or, (untested) you might be able to listen to all of form's child items' specialkey events:

    Code:
    init: function() {
            this.control({         
    		'form > textfield': {
    			specialkey: this.key
    		}
    	});
    },
      
    key: function() {
    	console.log('hello');
    }
    (I think this works, but didn't test it)
    Code:
    init: function() {
            this.control({         
    		'form > *': {
    			specialkey: this.key
    		}
    	});
    },
      
    key: function() {
    	console.log('hello');
    }

  3. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,154
    Answers
    501
    Vote Rating
    247
      0  

    Default

    The form panel itself doesn't have a specialkey event that you can listen to. But, the form fields that you'd put into a form panel often times do. So, you could listen to say all of the textfields or all of the combobox's specialkey events. Or, (untested) you might be able to listen to all of form's child items' specialkey events:

    Code:
    init: function() {
            this.control({         
    		'form > textfield': {
    			specialkey: this.key
    		}
    	});
    },
      
    key: function() {
    	console.log('hello');
    }
    (I think this works, but didn't test it)
    Code:
    init: function() {
            this.control({         
    		'form > *': {
    			specialkey: this.key
    		}
    	});
    },
      
    key: function() {
    	console.log('hello');
    }

  4. #3
    Sencha User
    Join Date
    May 2011
    Posts
    39
    Vote Rating
    0
      0  

    Default

    They both work. Thank you very much for the help!

  5. #4
    Sencha User
    Join Date
    Apr 2010
    Posts
    1
    Vote Rating
    0
      0  

    Default

    Excusme Im new and, I'm looking for something similar, I tried to get the event and execute a function but I don't undertand who is "this.control" is it my form? or mi field? I tried putting both but getting an error. Thanks for your help

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •