unregistering the ContextMenuHandler does not work?

I assume you have sth like this:

class YourWidget extends Composite implements ContextMenuHandler {

        HandlerRegistration registration;

        public YourWidget(){

                final HTML html =
                                new HTML("<div>Right-click here please 
;)</div>");
                Button setCustomMenuButton = new Button("Set Custom Menu");
                Button setNativeMenuButton = new Button("Set Native Menu");

                setCustomMenuButton.addClickHandler(new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
                                registration = addDomHandler(YourWidget.this,
                                                ContextMenuEvent.getType());
                        }
                });

                setNativeMenuButton.addClickHandler(new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
                                registration.removeHandler();
                        }
                });

                FlowPanel mainPanel = new FlowPanel();
                initWidget(mainPanel);

                mainPanel.add(html);
                mainPanel.add(setCustomMenuButton);
                mainPanel.add(setNativeMenuButton);

        }

        @Override
        public void onContextMenu(ContextMenuEvent event) {
                final int x = event.getNativeEvent().getClientX() +
                                Window.getScrollLeft();
                final int y = event.getNativeEvent().getClientY() +
                                Window.getScrollTop();
                final PopupPanel popup = new PopupPanel(true, true);
                popup.add(new HTML("my context menu"));
                popup.setPopupPositionAndShow(new PositionCallback() {
                        @Override
                        public void setPosition(int offsetWidth,
                                        int offsetHeight) {
                                popup.setPopupPosition(x, y);
                        }
                });
        }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to