对话框内的 gwt tabindex

发布于 2024-09-18 16:25:36 字数 361 浏览 5 评论 0原文

在我的 gwt 应用程序中,在某些屏幕上,我创建了一个带有输入表单的对话框。我希望能够使用 tabindex 属性,但只能在该对话框中使用。 (即:仅循环该对话框的第一个到最后一个字段)现在,如果我在选择最后一个字段时按 Tab,焦点将移动到恰好是对话框后面的项目的第一个选项卡索引(设置为 glass )。这非常烦人,因为现在必须按 Tab 键多次,直到焦点返回到第一个对话框字段。将对话框设置为模态的情况会更糟,只要您在对话框之外按 Tab 键,Tab 键就会被忽略,因为对话框外部的对象不再接收键盘事件(无法按 Tab 键退出!)。 我唯一的选择是监听 Tab 键并手动处理 Tab 键切换吗?只要它返回到我的对话框而无需浏览其下的所有元素,我就可以在应用程序之外使用 Tab 键切换到网址栏(例如)。

In my gwt app, on some screens, I create a dialogbox with an input form. I would like to be able to use the tabindex property but only within that dialog box. (ie: cycles first to last field of that dialog box only) Right now if I press tab when the last field is selected, the focus will move onto the first tab index that happens to be an item behind the dialog box (set as glass). This is quite annoying as one now has to tab several times until the focus returns to the first dialog box field. Setting the dialog box to modal is even worse as as soon as you tab outside the dialog box, the tab key gets ignored since objects outside the dialog box no longer receive keyboard events (can't tab out!).
Is my only option to listen for the tab key and handle tabbing manually? I would be fine with tabbing going outside my app and onto the url bar (for example) as long as it returns to my dialog box without having to go through all the elements under it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

于我来说 2024-09-25 16:25:36

好吧,迟到总比不到好!我也遇到过同样的问题。解决方案实际上很简单。

假设您有一个继承自Composite 的对话框,并包含用于数据输入和按钮的小部件。主窗口还包含一些 UI 小部件,例如输入字段和一些按钮。您为此主窗口设置 Tab 键顺序。当按下按钮调出对话框时,设置主窗口上的每个控件 (setTabIndex(-1)),以禁用 Tab 键顺序。

对于新对话框,在构造函数中注册以下代码:

this.addAttachHandler( new AttachEvent.Handler() {
    @Override
    public void onAttachOrDetach(AttachEvent event) {
        if(isAttached()) {
            setTabOrder();
        } else {
            clearTabOrder();
        }               
    }
});

然后创建两个根据需要调用的方法 setTabOrder()clearTabOrder()。看来 GWT 与具有 Tab 键顺序的多个窗口混淆了。您可以通过在显示/隐藏每个对话框窗口时动态创建 Tab 键顺序来结束混乱。

Well, better late than never! I've had the same issue. The solution is actually quite easy.

Let's say you have a dialog box that inherits from Composite and contains widgets for data entry and buttons. The main window also contains some UI widgets like entry fields and some buttons. You set up the tab order for this main window. When a button is pressed to bring up the dialog box, set each of the controls on the main window (setTabIndex(-1)) which disables tab order.

For the new dialog box, register the following code in the constructor:

this.addAttachHandler( new AttachEvent.Handler() {
    @Override
    public void onAttachOrDetach(AttachEvent event) {
        if(isAttached()) {
            setTabOrder();
        } else {
            clearTabOrder();
        }               
    }
});

and then create two methods setTabOrder() and clearTabOrder() that are called as appropriate. It seems that GWT gets confused with multiple windows with tab order. You can end the confusion by dynamically creating tab order when each dialog window is shown/hidden.

万水千山粽是情ミ 2024-09-25 16:25:36

好吧,在几乎一个月没有答案后,我决定采用手动 Tab 键处理。
工作起来就像一个魅力,但它现在忽略选项卡循环中的网址栏(对我来说很好)。
我用这篇博文开始:
http://albertattard.blogspot.com/2009 /11/capturing-tab-key-in-gwt-textarea.html
我只是在对话框的根部添加了一个焦点面板。

Well, after almost a month without an answer, I decided to go with manual tab key handling.
Works like a charm but it now ignores the url bar in the tab cycle (fine by me).
I used this blog post to get going:
http://albertattard.blogspot.com/2009/11/capturing-tab-key-in-gwt-textarea.html
I simply added a focus panel at the root of my dialog.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文