当用户在 Ext.form.field.HtmlEditor 中键入文本时捕获 Ctrl+Enter
当用户按下 时,我尝试发出 Ajax 请求在 Ext.form.field.HtmlEditor (xtype:'htmleditor') 中输入文本时按 Ctrl + Enter,但我不知道该怎么做。
我在“htmleditor”旁边有一个按钮,可以发送“htmleditor”的值,但我想使用 Ctrl + EnterCtrl 为该操作添加键盘快捷键kbd>。
它需要用 Ext JS 4 制作 - 不知怎的,我必须添加类似的东西我的 htmleditor 对象的“keypress”监听器...
这是代码...
this.htmleditor = this.addComment.add({
region: 'center',
xtype: 'htmleditor',
margin: '0 0 0 0',
enableSourceEdit: false,
height: 200
});
I'm trying to make an Ajax request when the user presses Ctrl + Enter while entering text in Ext.form.field.HtmlEditor (xtype:'htmleditor'), but I don't know how to do it.
I got a button next to the 'htmleditor' which can send the value of the 'htmleditor', but I'd like to add a keyboard shortcut for that operation with Ctrl + Enter.
It need to be made with Ext JS 4 - somehow I must add something like 'keypress' listener to my htmleditor object...
Here is the code...
this.htmleditor = this.addComment.add({
region: 'center',
xtype: 'htmleditor',
margin: '0 0 0 0',
enableSourceEdit: false,
height: 200
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您无法在默认 htmleditor 中监听事件。所以你需要使用它的更新版本。
此代码可以帮助您(它适用于 Ext JS 3,所以也许您需要将其更改为版本 4):
并且以您的形式:
我玩了很多 Ext JS 4 并找到了方法(您只需要包含此代码在使用 htmleditor 之前):
You cannot listen for events in the default htmleditor. So you need use an updated version of it.
This code can help you (it is for Ext JS 3, so maybe you need change it for version 4):
And in your form:
I played a lot with Ext JS 4 and found the way (you need just include this code before you'll use htmleditor):
这可能就是您想要的(已经在 Stack Overflow 上):< a href="https://stackoverflow.com/questions/1684196/ctrlenter-jquery-in-textarea">在 TEXTAREA 中使用 jQuery Ctrl + Enter:
This may be what you're after (was already on Stack Overflow): Ctrl + Enter using jQuery in a TEXTAREA:
这适用于 Ext JS 6(该示例禁用 Enter 键):
This worked for Ext JS 6 (the example disables the Enter key):