我有一个面板,我使用下面的代码呈现。Extjs面板。键盘事件
new Ext.Panel({
id: 'textPanel',
height: 1000,
width: 1200,
renderTo: Ext.getBody(),
html:"An HTML fragment, or a DomHelper specification to use as the layout element content. The HTML content is added after the component is rendered, so the document will not contain this HTML at the time the render event is fired. This content is inserted into the body before any configured contentEl is appended."
});
然后我想在按下回车键时收听事件。所以,我创建一个KeyMap如下...
var map = new Ext.KeyMap(Ext.getCmp('textPanel').body, {
key: Ext.EventObject.ENTER,
fn: onKeyPress,
// handler: onKeyPress,
scope: this
});
但onKeyPress函数没有被调用。
我一直在使用的
Ext.getCmp('textPanel').body.dom,
Ext.getCmp('textPanel').el.dom,
Ext.getCmp('textPanel').el
代替
Ext.getCmp('textPanel').body
没有成功已经尝试过。
如果我在那里使用“文档”,那么会调用onKeyPress函数。即
var map = new Ext.KeyMap(document, {
key: Ext.EventObject.ENTER,
fn: onKeyPress,
// handler: onKeyPress,
scope: this
});
这很好,但我不想听整个文档。 我怎样才能听到面板?
你是什么意思“听面板”吗?你的面板应该是'TextField'吗?在一个普通的“Ext.Panel”上听一个关键事件是没有意义的...... – kevhender
我的面板在它的主体中有文本。我想在面板的主体内按下输入或制表键时做一些事情。 –