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.