本文主要是介绍ExtJS 屏蔽backspace,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
/*** @author wangsr* @date 2012-09-06* 键盘事件管理*/ Ext.define("Gboat2.desktop.util.KeyManager", {alternateClassName : "GKeyManager",singleton : true,maskBackspace : function() {var DOC = Ext.getDoc();DOC.on({'keydown' : maskBS,'keyup' : maskBS});function maskBS(event, targetHtml) {var keycode = event.getKey();var obj = targetHtml;if (keycode == Ext.EventObject.BACKSPACE) {if (obj != null && obj.tagName != null&& (obj.tagName.toLowerCase() == "input" || obj.tagName.toLowerCase() == "textarea")) {//readOnlyvar fieldEl, fieldCmp;fieldEl = Ext.get(obj).up('table.x-form-item');if (fieldEl && fieldEl.id) {fieldCmp = Ext.getCmp(fieldEl.id);}if (fieldCmp && fieldCmp.readOnly) {event.stopEvent();}} else {event.stopEvent();}}}}});
这篇关于ExtJS 屏蔽backspace的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!