我有一个扩展smartgwt ImgButton的类。当按钮被按下时,应该显示一个包含更多按钮的弹出窗口。这个弹出窗口中的按钮不应该像普通按钮那样呈现,而应该像文本链接一样呈现-所以我应用了一个自定义的CSS类。到目前为止,一切运行正常。但是,当我按下弹出窗口中的任何一个按钮时,该按钮的背景变得透明,弹出窗口后面的文本闪闪发光。这很难看,但我找不到解决的办法。
有人知道如何在按下按钮时保持背景颜色吗?
代码如下:
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,我也不想编写我自己的代码。
发布于 2011-03-22 19:30:47
我刚学会怎么做。
我向按钮添加了样式主名称和样式名称,现在它可以工作了:)
因此,现在创建弹出窗口的按钮如下:
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);https://stackoverflow.com/questions/5389652
复制相似问题