带按钮的GWT PopupPanel
问题描述:
我有一个扩展了smartgwt ImgButton的类。当按下按钮时,应该显示包含更多按钮的弹出窗口。这个弹出框中的按钮不应该像普通按钮那样呈现,而应该像文本链接 - 所以我应用了一个自定义CSS类。到目前为止一切正常。但是,当我按下弹出窗口中的任何按钮时,按钮的背景变得透明,弹出窗口后面的文字闪烁。这很丑陋,但我找不到解决这个问题的方法。带按钮的GWT PopupPanel
有没有人有一个想法如何保持按钮被按下时的背景颜色?
下面是代码:
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.ImgButton;
import com.smartgwt.client.widgets.Button;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
public class MultiButton extends ImgButton {
private PopupPanel popup;
private VerticalPanel content;
public MultiButton() {
super();
popup = new PopupPanel();
popup.setAnimationEnabled(true);
popup.setAutoHideEnabled(true);
content = new VerticalPanel();
popup.add(content);
this.setWidth(18);
this.setHeight(18);
this.setShowRollOver(false);
this.setShowDown(false);
this.setSrc("person.png");
this.addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
popup.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
@Override
public void setPosition(int offsetWidth, int offsetHeight) {
int left = event.getX() + 7;
int top = event.getY() + 7;
popup.setPopupPosition(left, top);
}
});
}
});
}
public void addMultiButtonEntry(String name, ClickHandler handler) {
Button b = new Button(popup.getStyleName());
b.addClickHandler(handler);
b.setShowHover(false);
b.setShowRollOver(false);
b.setBaseStyle("nt-multibutton-button");
b.setAlign(Alignment.LEFT);
content.add(b);
}
}
,这是CSS定义:
.nt-multibutton-button {
border: 0px !important;
color: #657380;
font-size: 11px;
font-weight: bold;
text-align: left;
padding-left: 5px;
width:90%;
background-color: white;
}
感谢您的每一个提示! PS:我知道混合SmartGWT和GWT组件并不是很好的风格,但我没有在SmartGWT中找到PopUp,我也不想编写自己的代码。
答
我刚刚发现如何做到这一点。
我添加了一个风格主文件名和样式名称的按钮,现在它的工作原理:)
所以对于弹出按钮现在创建如下:
Button b = new Button(name);
b.addClickHandler(handler);
b.setShowHover(false);
b.setShowRollOver(false);
String css = "nt-multibutton-button";
b.setStylePrimaryName(css);
b.setBaseStyle(css);
b.setStyleName(css);
b.setAlign(Alignment.LEFT);
content.add(b);
你应该使用Firebug知道哪种风格对这种透明度负责,并尝试在CSS中覆盖它。它可能工作... – 2011-03-22 11:05:16