I'm not able to show a window that is defined class-level after hiding it. I need to use show & hide it whenever it's necessary.
Here's what I've tried so far:
isCapsLock Utility function for caps lock on/off handling:
function(e) {
e = (e) ? e : window.event;
var charCode = false;
if (e.which) {
charCode = e.which;
} else if (e.keyCode) {
charCode = e.keyCode;
}
var shifton = false;
if (e.shiftKey) {
shifton = e.shiftKey;
} else if (e.modifiers) {
shifton = !!(e.modifiers & 4);
}
if (charCode >= 97 && charCode <= 122 && shifton) {
return true;
}
if (charCode >= 65 && charCode <= 90 && !shifton) {
return true;
}
return false;
}
Ext.define('MyApp.controller.LoginController', {
extend : 'Ext.app.Controller',
views : [ 'notification.CapsLockNotification' ],
refs : [{
ref : 'capsLockNotification',
selector: 'capslocknotification'
}],
init : function() {
this.capsLockNotification = Ext.widget('capslocknotification');
this.control({
'loginform #password' : {
keypress : this.handleCapsLock
}
// control logic goes here
});
},
handleCapsLock : function(field, eOpts) {
var win = this.getCapsLockNotification();
if(ExtUtil.isCapsLock(eOpts)) {
win.show();
} else {
win.hide();
}
}
});