有个设置快捷键的问题我弄了两天了还是没弄出来。郁闷
要给Extjs 中的htmleditor设置快捷键,当按键盘的enter键或者什么键就可以执行某种操作。我试了好多方法,,,keymap都貌似不起作用。
谁有做过这方面的东西没有?
要给Extjs 中的htmleditor设置快捷键,当按键盘的enter键或者什么键就可以执行某种操作。我试了好多方法,,,keymap都貌似不起作用。
谁有做过这方面的东西没有?
解决方案 »
- 在jsp页面中表单中的值如何保存在本地硬盘呢,我知道要用到java.IO的知识,可是不知道该怎么实现
- 菜鸟求教
- 深圳从事j2ee的请进
- Unix与windows下换行符的问题??? 在程序中如何转换(小弟刚注册的号,没多少分)
- J2EE可以自学吗?
- 实体bean的疑惑-------------请教
- java在企业应用上能否用c/s结构
- 页面文件上传--文件选择器如何限定文件类型
- 急急,搞一天了,JB7+WEBLOGIC7开发,servlet同步更新大家是怎么解决的??!!
- j2ee下的EJB调用出现的问题??急救!
- 求助,比较字符串后4位的HQL和SQL语句!
- 怎么让String字符串显示在textarea中急......................
if(keyEvent.getKey() == 13){
alert("Enter Key!!");
}
}};
比htmleditor 强太多了
* 重写Ext.form.HtmlEditor,为其添加键盘事件
* author: hoojo
* email: [email protected]
* blog: http://blog.csdn.net/IBM_hoojo
* create by: 2010-8-14
* ext-lib: 3.2.1
* version: 1.0
*/
Ext.override(Ext.form.HtmlEditor, {
initEditor : function(){
var dbody = this.getEditorBody();
var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
ss['background-attachment'] = 'fixed'; // w3c
ss['background-color'] = 'white';
dbody.bgProperties = 'fixed'; // ie
Ext.DomHelper.applyStyles(dbody, ss);
if(this.doc){
try{
Ext.EventManager.removeAll(this.doc);
}catch(e){}
}
this.doc = this.getDoc();
Ext.EventManager.on(this.doc, {
'mousedown': this.onEditorEvent,
'dblclick': this.onEditorEvent,
'click': this.onEditorEvent,
'keyup': this.onEditorKeyUpEvent,
'keydown': this.onEditorKeyDownEvent,
'keypress': this.onEditorKeyPressEvent,
buffer:100,
scope: this
});
if(Ext.isGecko){
Ext.EventManager.on(this.doc, 'keypress', this.applyCommand, this);
}
if(Ext.isIE || Ext.isSafari || Ext.isOpera){
Ext.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
}
this.initialized = true;
this.fireEvent('initialize', this);
this.doc.editorInitialized = true;
this.pushValue();
},
initComponent: function () {
this.addEvents(
'initialize',
'activate',
'beforesync',
'beforepush',
'sync',
'push',
'editmodechange',
'keydown',
'keyup',
'keypress'
);
},
onEditorKeyPressEvent : function(e){
this.updateToolbar();
this.fireEvent("keypress", this, e);
},
onEditorKeyUpEvent : function(e){
this.updateToolbar();
this.fireEvent("keyup", this, e);
},
onEditorKeyDownEvent : function(e){
this.updateToolbar();
this.fireEvent("keydown", this, e);
}
});
在js中加入这段代码应该就可以了
new Ext.Panel( {
region:'south',
layout:'fit',
items:{
xtype:'htmleditor',
name :'content',
id:'content',
listeners:{
'render' : function(editor){
var ifameDom = editor.getEl().dom.nextSibling.contentWindow;
if(ifameDom){
if (window.attachEvent){
alert(1);
ifameDom.document.attachEvent('onkeyup',function(e){
if(e.ctrlKey && e.keyCode == 13){
alert("1:"+1313);
}
})
}else{
ifameDom.addEventListener('keyup', function(e){
if(e.ctrlKey && e.keyCode == 13){
alert("2:"+1313);
}
}, false);
}
}
}
}
}
}) new Ext.Panel( {
layout:'fit',
items:{
xtype:'htmleditor',
name :'content',
id:'content'
}
}), 上面就是我的代码, ifameDom.document.attachEvent('onkeyup',function(e){}关于键盘的这个事件没有运行了。
现在又有两个新问题请教了。1.在window加载完成后给htmleditor聚焦为什么不行。
我的代码是这么写的。
var htmleditor=Ext.getCmp("htmleditor");
if(htmleditor.isVisible()==true)
{
htmleditor.focus(true);
}
2.window加载htmleditor后,为什么有时候htmleditor是处于可编辑状态有时候加载完成是不可编辑的,不可编辑时必须要点一下字体选择的下拉框才可以在里面输入内容。这是什么问题???跟IE有关还是它本身的bug。