Thanks, that did it! On Jul 30, 3:00 pm, lineman78 <[email protected]> wrote: > You are using the older method of event handling. This method works > fine for me: > > addDomHandler(new ContextMenuHandler() > { > @Override > public void onContextMenu(ContextMenuEvent event) > { > showMenu(); > event.preventDefault(); > } > }, ContextMenuEvent.getType()); > > On Jul 30, 11:16 am, BrianP <[email protected]> wrote: > > > > > I'm trying to capture right-clicks on a widget, to popup my own > > context menu instead of the browser's. I've researched it a bit and > > pieced together bits and I've got it working in Chrome and FF but not > > IE. In IE it doesn't display the default browser context menu, but it > > doesn't display my popup menu either. I'm just getting into GWT so I'm > > assuming I'm not doing something right with the right kinds of > > handlers or events. I'm also using the gwt-graphics module, that's > > where the Rectangle class that I'm extending comes from, in case > > that's relevant. > > > Here's my code: > > > public class RectangleRightClickable extends Rectangle { > > > public RectangleRightClickable(int x, int y, int width, int height) { > > super(x, y, width, height); > > sinkEvents(Event.ONCONTEXTMENU); > > > } > > > public void onBrowserEvent(Event event) { > > GWT.log("onBrowserEvent"); > > event.stopPropagation(); > > event.preventDefault(); > > GWT.log("event type : " + DOM.eventGetType(event)); > > switch(DOM.eventGetType(event)) { > > case Event.ONCONTEXTMENU: > > if (DOM.eventGetButton(event) == Event.BUTTON_RIGHT) { > > GWT.log("Event.BUTTON_RIGHT", null); > > showMenu(); > > } > > break; > > default: > > GWT.log(event.toString()); > > break; > > } > > > } > > > protected void showMenu() { > > final RectangleRightClickable parent = this; > > final PopupMenu popMenu = new PopupMenu(); > > popMenu.addMenuItem(new Label("Add thing")); > > popMenu.setPopupPositionAndShow(new PopupPanel.PositionCallback() > > { > > public void setPosition(int offsetWidth, int offsetHeight) { > > int left = parent.getX() + parent.getWidth(); > > int top = parent.getY() + parent.getWidth(); > > popMenu.setPopupPosition(left, top); > > } > > }); > > > } > > }
-- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
