GWT MenuBar.Resources...被忽略?

发布于 2024-10-29 23:01:09 字数 753 浏览 5 评论 0原文

我正在创建一个 MenuBar,我想让它在有要显示的子元素时显示一个小图标。我以为我可以像这样实现这一点:

interface ActionHeroResources extends ClientBundle, MenuBar.Resources
{
    @Source("actionhero.css")
    public ActionHeroCSS css();

    @Override
    @Source("agw-dropdown.png")
    ImageResource menuBarSubMenuIcon();
}

private static final ActionHeroResources RESOURCES = GWT.create(ActionHeroResources.class);

MenuBar actionMenu = new MenuBar(true, RESOURCES);

public ActionHero()
{
    actionMenu.addItem("Select", aSelectMenuFullOfOptions);
}

但是菜单中出现“选择”一词,但没有图标!我确信我的 ImageResource 工作正常,因为我稍后使用同一资源中的 menuBarSubMenuIcon().getURL() ,并且我的图像正如您所期望的那样显示。在 GWT 生成的 HTML 中,以 MenuBar 作为子项的项和以 Commands 的项之间绝对没有区别。我的 CSS 工作正常。

有什么想法吗?

I'm creating a MenuBar, and I want to have it display a little icon when there are sub-elements to be displayed. I thought I could achieve this like so:

interface ActionHeroResources extends ClientBundle, MenuBar.Resources
{
    @Source("actionhero.css")
    public ActionHeroCSS css();

    @Override
    @Source("agw-dropdown.png")
    ImageResource menuBarSubMenuIcon();
}

private static final ActionHeroResources RESOURCES = GWT.create(ActionHeroResources.class);

MenuBar actionMenu = new MenuBar(true, RESOURCES);

public ActionHero()
{
    actionMenu.addItem("Select", aSelectMenuFullOfOptions);
}

But the menu appears with the word "Select" an no icon! I'm positive my ImageResource is working correctly because I use menuBarSubMenuIcon().getURL() from the same resource later, and my image shows up just as you'd expect. In the HTML generated by GWT, there is absolutely no distinction between the items with MenuBars as children and the items with Commands. My CSS is working fine.

Any thoughts?

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

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

发布评论

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

评论(3

ぇ气 2024-11-05 23:01:09

尝试覆盖 .gwt-MenuBar-vertical .subMenuIcon-selected 的 CSS 样式,如下所示:

.gwt-MenuBar-vertical .subMenuIcon-selected {
    background: none;
}

我将其用于我自己选择的项目,效果很好:

.gwt-MenuBar-vertical .subMenuIcon-selected {
    background: url(images/hand_pointer.png) no-repeat 0px 0px;
}

Try overriding the CSS style for .gwt-MenuBar-vertical .subMenuIcon-selected, like this:

.gwt-MenuBar-vertical .subMenuIcon-selected {
    background: none;
}

I use this for my own selected items and it works great:

.gwt-MenuBar-vertical .subMenuIcon-selected {
    background: url(images/hand_pointer.png) no-repeat 0px 0px;
}
眼波传意 2024-11-05 23:01:09

问题最终是形成子菜单的弹出面板从父菜单中获取样式名称,但附加一个依赖的样式名称。我不知道有什么方法可以预测依赖的样式名称是什么,因为原始样式名称被混淆了。我通过使用更通用的 .gwt-MenuBar 弹出样式名称解决了这个问题。这只有效,因为我的程序中只有一种样式的弹出菜单 - 我不确定如果我想让两个弹出窗口看起来不同我会做什么!

希望在以后的 gwt 版本中,MenuBar 样式将更接近传递给菜单栏的资源,并减少使用依赖样式名称。

The problem was ultimately that the popup panels that form the submenus take their stylename from the parent, but append a dependent stylename. I don't know of a way to predict what that dependent stylename will be, since the original stylename is obfuscated. I worked around this problem by using the more generic .gwt-MenuBar popup stylename. This only works because I only have one style of popup menu in my program - I'm not sure what I would do if I wanted two popups to look different!

Hopefully, in later gwt releases, the MenuBar styles will come more closely from the resources passed to the menubar and make less use of dependent style names.

素罗衫 2024-11-05 23:01:09

您可以简单地为子菜单中显示的 CSS 规则设置如下:

.subMenuIcon > img {
    /* override gwt sub menu icon */
    width: 6px !important;
    height: 11px !important;
    background: url('your-image-relative-path.png') no-repeat 0px 0px !important;
}

You can simply set a css rule for the that appears in the sub menu like this:

.subMenuIcon > img {
    /* override gwt sub menu icon */
    width: 6px !important;
    height: 11px !important;
    background: url('your-image-relative-path.png') no-repeat 0px 0px !important;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文