GWT:如何在按下按键的位置显示弹出窗口 [英] GWT:how to display a popup at the poistion of the key pressed

查看:129
本文介绍了GWT:如何在按下按键的位置显示弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在eclipse中输入ctl + space时显示一个单词建议列表。
为此,我需要知道用户输入ctrl +空格的位置,以便我可以将建议列表完全显示在刚刚输入的用户字词中。



我看到了获取鼠标光标位置的方法,但是没有办法让键盘按钮按下位置,
我在textArea中写入内容,我尝试了getCursor,但是它给了我用户输入的字号Ctrl +空格键。

任何想法



谢谢

解决方案

没有可靠,准确和跨浏览器的方式来处理TextArea。



您可以尝试使用RichTextArea(您不必为富文本功能提供工具栏)和它的 getFormatter()。insertHTML()方法。它会在光标位置插入一个新的HTML元素。您可以插入建议词汇列表,您可以根据自己的喜好设计样式,或者插入一个空的 div 并尝试显示相对于它的面板



或者您可以使用其他UI方法。创建一个相对于TextArea具有固定位置的面板并在那里显示您的建议词 - 类似于智能手机键盘在键盘本身上方显示建议词的方式。一旦用户意识到建议的话总是出现在同一个地方,他们甚至可能更喜欢这个设计。


I am trying to display a word suggestion list when ctl+space entered as in eclipse. For that I need to know the location where user has entered ctrl+space so that i can display the suggestion list exact below to the word user just entered.

I see ways to get the mouse cursor position , But isnt there a way to get the keyboard button pressed position , I am writing inside textArea, I tried getCursor, but it gives me the no of word on which user entered ctrl+space. Not the location as per the Window.

Any idea

thanks

解决方案

There is no reliable, accurate and cross-browser way to do it with TextArea.

You can experiment with a RichTextArea (you don't have to provide a toolbar for rich text features) and its getFormatter().insertHTML() method. It will insert a new HTML element at a cursor position. You can insert a list of suggested words, that you can style to look anyway you like, or you can insert an empty div and try to show a panel relative to it.

Or you can use a different UI approach. Create a panel with a fixed position relative to your TextArea and show your suggested words there - similar to the way good smartphone keyboards show suggested words just above the keyboard itself. Once your users realize that suggested words always show up in the same place, they may even like this design better.

这篇关于GWT:如何在按下按键的位置显示弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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