在为CKEditor对话框插件调用setValueOf时避免文本字段获得焦点
我有一个CKEditor对话框插件,如下所示在为CKEditor对话框插件调用setValueOf时避免文本字段获得焦点,ckeditor,Ckeditor,我有一个CKEditor对话框插件,如下所示 CKEDITOR.dialog.add('myDialog', function( editor ) { editor.on( 'dialogShow', function( dialogShowEvent ) { ... dialog.setValueOf('tab-xxx', 'seperator', ", "); }); return { title: 'xx
CKEDITOR.dialog.add('myDialog', function( editor ) {
editor.on( 'dialogShow', function( dialogShowEvent )
{
...
dialog.setValueOf('tab-xxx', 'seperator', ", ");
});
return {
title: 'xxx',
minWidth: 200,
minHeight: 100,
contents: [
{
id: 'tab-xxx',
label: 'xxx',
elements: [
{
type: 'text',
id: 'seperator',
label: 'xxx'
}]
}
],
当对文本字段执行dialog.setValueOf
时,它将自动获得焦点。这导致选择了整个值
我希望避免新插入的值被选中。我试图将注意力转移到其他UI组件上
CKEDITOR.dialog.add('myDialog', function( editor ) {
editor.on( 'dialogShow', function( dialogShowEvent )
{
...
dialog.setValueOf('tab-xxx', 'seperator', ", ");
// Shift the focus, hopefully the text in 'seperator' will not be selected.
dialog._.buttons['ok'].focus();
});
然而,这没有帮助。我可以知道这样做的正确方法吗?您确定
setValueOf()
将焦点移动到输入字段吗?TBH,我发现这不太可能,我甚至现在检查了一下,如果焦点在一个按钮上,它会留在那里。你能做个样品吗?很确定。当我删除setValueOf
时,不会选择任何文本。如果我返回setValueOf
,将选择文本。我将看看我如何能提供一个最低限度的可行的样品。