GWT MenuBar.Resources...被忽略?
我正在创建一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试覆盖 .gwt-MenuBar-vertical .subMenuIcon-selected 的 CSS 样式,如下所示:
我将其用于我自己选择的项目,效果很好:
Try overriding the CSS style for .gwt-MenuBar-vertical .subMenuIcon-selected, like this:
I use this for my own selected items and it works great:
问题最终是形成子菜单的弹出面板从父菜单中获取样式名称,但附加一个依赖的样式名称。我不知道有什么方法可以预测依赖的样式名称是什么,因为原始样式名称被混淆了。我通过使用更通用的 .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.
您可以简单地为子菜单中显示的 CSS 规则设置如下:
You can simply set a css rule for the that appears in the sub menu like this: