如何从GWT中的RichTextArea获取光标位置或位置? [英] How to get cursor position or location from RichTextArea in GWT?

查看:195
本文介绍了如何从GWT中的RichTextArea获取光标位置或位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从RichTextArea获取光标位置或位置。
我不知道如何获取当前光标位置没有任何鼠标事件。
例如TextArea有方法getCursorPos(),但RichTextArea没有像TextArea的方法。
任何人都有什么想法?请帮助我...

I want to get cursor position or the location from RichTextArea. I do not know how to get current cursor position Without any mouse event. e.g. TextArea has method getCursorPos(), but RichTextArea does not have method like TextArea. Anyone have any idea? Please help me...

提前感谢...

推荐答案

p>如果你想在RichTextArea的光标位置插入一些东西,你可以使用格式化程序:

If you you want to insert something in the RichTextArea at the cursor position, you can do it with the formatter:

RichTextArea.Formatter formatter = richText.getFormatter();
formatter.insertHTML("My text is inserted at the cursor position");

要使用JavaScript查找光标位置,请尝试Tim Down提出的解决方案:

To find a cursor position using JavaScript, try the solution proposed by Tim Down:

获取范围的起始和结束偏移量相对于其父容器

这篇关于如何从GWT中的RichTextArea获取光标位置或位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆