walter
walter

Reputation: 309

Onclick event in GWT custom button in title bar of DialogBox

I need to add button in title bar of the DialogBox that open some documentation;

My HelpButton class looks like this:

public class HelpButtonSmall extends Button {


    public HelpButtonSmall(final String name) {
        super();
        setHTML("<input type=\"image\" src=\"/img/ico-help-sm.png\" name=\"image\">");
        addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                Window.alert("Help");

            }
        });
    }       
}

On my dialog box I'm adding button in title bar like this:

HTML caption = ((HTML)this.getCaption());
HelpButtonSmall smallButton = new HelpButtonSmall("Show help alert");
caption.getElement().appendChild(smallButton.getElement());

The problem is that after clicking on button alert message doesn't show.

Please help me resolve this issue.

Upvotes: 0

Views: 177

Answers (1)

Momo
Momo

Reputation: 2491

When using getElement() you are returning a native handler of DOM element and by doing that any logic done as a Widget is lost, that includs the addClickHandler.

If the perpose is to add a close button, there is other ways to achieve that. Here is one of theme.

Upvotes: 1

Related Questions