为什么GWT中没有isFocused()? [英] Why is there no isFocused() in GWT?

查看:150
本文介绍了为什么GWT中没有isFocused()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编程场景中,我需要检查我的GWT文本框是否被关注。我最终添加了一个布尔值和一对Focus& BlurHandler手动保持焦点状态,这让我想知道为什么没有这样的方法,如果焦点组件集中在gwt中,返回这样的方法? 解决方案

因为在几年前没有任何跨浏览器的方式(Firefox 3,Safari 4,指出游戏中最后的玩家添加了支持 document.activeElement )。
$ b

GWT仍然正式支持[1] Safari 3(我相信Safari 2的支持已被弃用),甚至Firefox 2(无DevMode插件,但这并不意味着浏览器不被支持:Opera支持,但没有DevMode),所以它不可能提供这样的功能,可以在所有支持的浏览器中工作。



最后但并非最不重要的是,我认为没有人提出过问题追踪器的增强请求(至少我找不到);正如你所说,现在已经可以使用FocusHandler / BlurHandler(它可以跨浏览器)工作。
$ b [1] http://code.google.com/webtoolkit/doc/latest/FAQ_GettingStarted.html#What_browsers_does_GWT_support ?我相信这个页面已经过时了,因为它仍然列出了Firefox 1.0,它的支持(user.agent = gecko,gecko1_8)已经在GWT 2.1.0中删除,并且没有列出IE9,它的支持已被添加到GWT 2.3.0中,最后但并非最不重要的一点,我相信只支持Opera的最新版本,而列表中则讨论了Opera 9。


In a programming scenario, I needed to check if my GWT textbox was focused or not. I ended up adding a boolean and a pair of Focus & BlurHandler to manually keep the focus state which makes me wonder why is there no such method that returns if a focusable component is focused in gwt?

解决方案

Because there wasn't any cross-browser way of doing it until a few years ago (Firefox 3, Safari 4, to point at the last players in the game having added support document.activeElement).

GWT still officially supports [1] Safari 3 (I believe Safari 2 support has been deprecated) and maybe even Firefox 2 (no DevMode plugin, but that doesn't mean the browser isn't supported: Opera is supported but has no DevMode either), so it's not possible to provide such a feature that would work in all supported browsers.

Last, but not least, I think no one ever filed a request for enhancement in the issue tracker (I couldn't find any at least); and as you said, you can already do it today using FocusHandler/BlurHandler (which works cross-browser).

[1] http://code.google.com/webtoolkit/doc/latest/FAQ_GettingStarted.html#What_browsers_does_GWT_support? I believe that page is a bit out of date, as it still lists Firefox 1.0, whose support (user.agent=gecko, vs. gecko1_8) has been removed in GWT 2.1.0, and doesn't list IE9, whose support has been added in GWT 2.3.0, and last but not least, I believe only the latest version of Opera is supported, whereas the list talks about Opera 9.

这篇关于为什么GWT中没有isFocused()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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