选择 GWT SuggestBox 焦点上的所有内容
我一直在搜索,但找不到在焦点上选择 GWT SuggestBox 小部件中所有文本的可用示例。我知道您必须将 focusListener 附加到小部件,但是然后呢?有人可以提供一个可行的例子吗?
I've been searching and searching and can't find a usable example of selecting all text within a GWT SuggestBox widget on focus. I understand you have to attach a focusListener to the widget, but then what? Can someone provide a working example of this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于我在网上找到的每个示例都使用已弃用的代码(addFocusListener 方法),因此我最终使用 addFocusHandler 方法来解决这个问题。
这是如何完成的:
Since every example I'd found online was using deprecated code (addFocusListener method), I ended up figuring this one out using the addFocusHandler method instead.
Here's how it was done:
我只是在创建 SuggestBox 时将“addFocusListener”应用到 SuggestBox 内的“TextBox”(其中,当您需要创建 SuggestBox 时,可以访问 TextBox 本身)。我想在某种程度上,这种方式更符合逻辑。
I simply applied "addFocusListener" to the "TextBox" inside the SuggestBox in the creation of the SuggestBox (where the TextBox itself is reachable as you need it for the creation of the SuggestBox). I guess that in a way it's more logical this way.