首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带按钮的GWT PopupPanel

带按钮的GWT PopupPanel
EN

Stack Overflow用户
提问于 2011-03-22 18:11:27
回答 1查看 5K关注 0票数 0

我有一个扩展smartgwt ImgButton的类。当按钮被按下时,应该显示一个包含更多按钮的弹出窗口。这个弹出窗口中的按钮不应该像普通按钮那样呈现,而应该像文本链接一样呈现-所以我应用了一个自定义的CSS类。到目前为止,一切运行正常。但是,当我按下弹出窗口中的任何一个按钮时,该按钮的背景变得透明,弹出窗口后面的文本闪闪发光。这很难看,但我找不到解决的办法。

有人知道如何在按下按钮时保持背景颜色吗?

代码如下:

代码语言:javascript
复制
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的定义:

代码语言:javascript
复制
.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,我也不想编写我自己的代码。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-03-22 19:30:47

我刚学会怎么做。

我向按钮添加了样式主名称和样式名称,现在它可以工作了:)

因此,现在创建弹出窗口的按钮如下:

代码语言:javascript
复制
    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);
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5389652

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档