ExtJS:在消息框中覆盖OnEsc

时间:2016-08-05 00:28:09

标签: extjs event-handling

无法制作' onEsc'处理消息框的处理程序。当用emptyFn覆盖时,按ESC键仍然会关闭对话框。自定义onEsc永远不会被触发。

Ext.Msg.show({
            msg: "message",
            title: "title",
            maxWidth: 420,
            minWidth: 300,
            onEsc: Ext.emptyFn
        });

https://fiddle.sencha.com/#fiddle/1eqo

1 个答案:

答案 0 :(得分:0)

问题是onEsc是实例上的属性,无法应用于单例Ext.Msg。解决方案是将其设置在Ext.window.MessageBox class:

的新实例上
Ext.create('Ext.window.MessageBox', {            
    onEsc: Ext.emptyFn}).
show(<config>);

new Ext.window.MessageBox({            
    onEsc: Ext.emptyFn}).
show(<config>);