Threaded View

  1. #1
    Sencha User
    Join Date
    Nov 2010
    Posts
    48
    Vote Rating
    0
    nil5286 is on a distinguished road

      0  

    Default Unanswered: Attach F9 keymap binding to Checkbox

    Unanswered: Attach F9 keymap binding to Checkbox


    hi,
    I want to uncheck the checkbox on click of f9 key.

    I tried the below code:

    Code:
    <script type="text/javascript">
        Ext.onReady(function () { 
          var checkbox = Ext.create("Ext.form.field.Checkbox",
            {
              id: "checkbox_ID",
              renderTo: "checkbox_DIV",
              boxLabel: "Checkbox Test",
          clearFieldFn: function () {
                var me = this;
                me.setValue(false);
         },
             listeners:
                {
                  afterrender: function(checkbox)
                    {
                        checkbox.inputEl.on('keyup', function (field, e) {
                            if (e.getKey() == Ext.EventObject.F9) {
                                field.clearFieldFn();
                            }
                        });
                                        
                        checkbox.labelEl.on('keyup', function (field, e) {
                            if (e.getKey() == Ext.EventObject.F9) {
                                field.clearFieldFn();
                            }
                        });
                        checkbox.getEl().on('keyup', function (field, e) {
                            if (e.getKey() == Ext.EventObject.F9) {
                                field.clearFieldFn();
                            }
                        });                    
               checkbox.getEl().addKeyMap({
                eventName: "keyup",
                binding: [{
                    key: Ext.EventObject.F9,
                    fn: function () {
                        this.clearFieldFn();
                    },
                    scope: checkbox
                    }]
              });
                    }             
                 }
              });        
            });
    </script>
    </head>
    <body>
      <div id="checkbox_DIV"></div>
    </body>
    </html>
    Thanks in advance.
    Last edited by nil5286; 28 Feb 2013 at 5:38 AM. Reason: forgot to mention a part of code

Thread Participants: 1

Tags for this Thread