使用 GWT 的 TabLayoutPanel 在选项卡旁边添加任意文本

发布于 2024-11-08 21:37:29 字数 188 浏览 6 评论 0原文

目前,我有一个带有几个选项卡的 TabLayoutPanel,每个选项卡内部是一组面包屑。我希望能够在选项卡旁边(在 TabBar 本身内部)显示我的面包屑。我还没有看到有人这样做的任何实例,我开始相信我最终可能会自己重写他们的 TabLayoutPanel 类并在需要的地方实现它,但显然我宁愿不走这条路,除非别无选择。

有人对此有任何指导吗?

Currently, I have a TabLayoutPanel with a few tabs, inside of each tab is a set of breadcrumbs. I would like to be able to display my breadcrumbs right next to the tabs (inside the TabBar itself). I haven't yet seen any instance of someone having done this, and I'm beginning to believe I might end up rewriting their TabLayoutPanel class myself and implementing that where needed, but obviously I'd rather not go that route unless there's no alternative.

Anyone have any guidance on this?

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

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

发布评论

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

评论(1

枕花眠 2024-11-15 21:37:29

刚刚遇到同样的问题。以下是大部分相关代码片段。我在选择选项卡时添加了一个 Unicode 箭头,并在取消选择选项卡时将其删除。

    private final String htmlStr ="\u25bb";

        private String getTabTitle(String html){
        // Designed to work for this example input.
        //If you pass a different string you will need to do different matching.
        if(html.indexOf("\u25bb") < 0)
            return html;
        else
            return html.substring(html.indexOf("\u25bb")+1);
    }


    @Override
 public void onBeforeSelection(BeforeSelectionEvent<Integer> event) {
        if(!getSelectedIndex().equals(event.getItem())) {
            notifyCurrentTabOfClosing();
            selectedIndex = event.getItem();
            String tabtitle = getTabTitle(getTabBar().getTabHTML(selectedIndex));
            getTabBar().setTabHTML(selectedIndex, htmlStr+tabtitle);
            }
        }
    }

public void selectTab(Widget widget) {
        int widgetIndex = getWidgetIndex(widget);
        selectTab(widgetIndex);
        String tabtitle = getTabTitle(getTabBar().getTabHTML(widgetIndex));
        getTabBar().setTabHTML(widgetIndex, htmlStr+tabtitle);
    }

Just came across the same problem. Here are most of the relevent code snippets. I added a Unicode arrow when the tab was selected, and removed it when the tab was deselected.

    private final String htmlStr ="\u25bb";

        private String getTabTitle(String html){
        // Designed to work for this example input.
        //If you pass a different string you will need to do different matching.
        if(html.indexOf("\u25bb") < 0)
            return html;
        else
            return html.substring(html.indexOf("\u25bb")+1);
    }


    @Override
 public void onBeforeSelection(BeforeSelectionEvent<Integer> event) {
        if(!getSelectedIndex().equals(event.getItem())) {
            notifyCurrentTabOfClosing();
            selectedIndex = event.getItem();
            String tabtitle = getTabTitle(getTabBar().getTabHTML(selectedIndex));
            getTabBar().setTabHTML(selectedIndex, htmlStr+tabtitle);
            }
        }
    }

public void selectTab(Widget widget) {
        int widgetIndex = getWidgetIndex(widget);
        selectTab(widgetIndex);
        String tabtitle = getTabTitle(getTabBar().getTabHTML(widgetIndex));
        getTabBar().setTabHTML(widgetIndex, htmlStr+tabtitle);
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文