Ext JS 4 TextArea - 如何设置插入点?
是否可能/如何设置 ExtJS 4 Textarea 的插入点?
我想插入一些文本(我正在工作),然后我想将插入点设置为从字段开头开始的特定长度:
我正在获取当前内容,在前面插入一些文本。现在我想将插入点移到“-”之后:
//field = my ExtJS text area
var ins = "some text I inserted - \r";
var value = ins + field.getValue();
field.setValue(value);
Is it possible / how do you set the insertion point for an ExtJS 4 Textarea?
I want to insert some text (which I have working), then I want to set the insertion point at a specific length from the beginning of the field:
I am getting the current contents, inserting some text in front. Now I want to move the insertion point to right after the "-":
//field = my ExtJS text area
var ins = "some text I inserted - \r";
var value = ins + field.getValue();
field.setValue(value);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有现成的方法可以实现这一点。
Javascript 安全性不允许您触发按键事件,因此您无法聚焦文本区域,然后触发“CTRL+END”组合键,甚至“END”键。
我在
所以我的答案是,在正式支持之前,您不应该尝试此操作,因为即使您进行了破解,它也可能只能在某些浏览器中正常运行。
There's no out-of-the-box method that allows this.
Javascript security doesn't allow you to fire a keypress event, so you can't focus the textarea and then fire the "CTRL+END" key combo, or even the "END" key, for example.
I played around with the
focus()
andselect()
methods on the<textarea>
element, with no success being able to get the cursor to appear at the end.So my answer is that you shouldn't attempt this until it's officially supported, because even if you get a hack to work, it might only function properly in some browsers.
qaScriptForm 是普通表单
Script 是普通 TextArea
qaScriptForm is a normal form
Script is a normal TextArea