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

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

问题描述

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

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?

推荐答案

因为直到几年前还没有任何跨浏览器的方式来做到这一点(Firefox 3,Safari 4,指向最后的玩家游戏已添加支持 document.activeElement).

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 仍然正式支持 [1] Safari 3(我相信 Safari 2 支持已被弃用)甚至 Firefox 2(没有 DevMode 插件,但这并不意味着不支持浏览器:支持 Opera,但有也没有 DevMode),因此不可能提供在所有支持的浏览器中都可以使用的功能.

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.

最后,但并非最不重要的一点,我认为没有人曾在问题跟踪器中提交过增强请求(至少我找不到);正如您所说,您今天已经可以使用 FocusHandler/BlurHandler(跨浏览器工作)来做到这一点.

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?我认为该页面有点过时,因为它仍然列出了 Firefox 1.0,其支持(user.agent=gecko,vs. gecko1_8)已在 GWT 2.1.0 中删除,并且没有列出 IE9,其支持已已在 GWT 2.3.0 中添加,最后但并非最不重要的是,我相信仅支持最新版本的 Opera,而列表中讨论的是 Opera 9.

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