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

查看:20
本文介绍了如何从 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...

提前致谢...

推荐答案

如果你想在 RichTextArea 的光标位置插入一些东西,你可以用 formatter 来做:

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天全站免登陆