In the application html file ensure you have set up body tag like - <body
*oncontextmenu="return
false;"*>
This suppresses the *default *browser context menu.
On Tuesday, 6 March 2012 09:26:13 UTC+5:30, Daniel Mauricio Patino León
wrote:
>
> Iam trying to figure out how to implement a right click to my
> DataGrid, here is my code:
>
> @UiField(provided=true) DataGrid<EmployeeProxy> dataGrid = new
> DataGrid<EmployeeProxy>(){
> protected void onBrowserEvent2(Event event) {
> switch (DOM.eventGetType(event)) {
> case Event.ONMOUSEDOWN:
> if (DOM.eventGetButton(event) ==
> Event.BUTTON_RIGHT) {
>
>
> event.preventDefault();
> event.stopPropagation();
>
>
> PopupPanel pop = new PopupPanel(true);
>
> MenuBar menuBar = new MenuBar(true);
> menuBar.setVisible(true);
> menuBar.addItem(new MenuItem("Click
> me", new Command() {
>
> @Override
> public void execute() {
> Window.alert("Clicked
> me!");
> }
> }));
> menuBar.addItem(new MenuItem("Poke
> me",new Command(){
> @Override
> public void
> execute() {
>
> Window.alert("Poked
> me!");
> }
> }));
>
> pop.setWidget(menuBar);
>
>
> pop.setPopupPosition(DOM.eventGetClientX(event)
> ,DOM.eventGetClientY(event));
> pop.show();
>
> } else {
> super.onBrowserEvent2(event);
> }
> break;
> default:
> super.onBrowserEvent2(event);
> break;
> }
> };
> };
>
>
> This works ok but dont know how to prevent the default browser right
> click behavior.
>
>
> Any help would be nice. Thank you.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/fKgliG4HeB4J.
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.