Re: How can I disable the browser's default right click response?

620 views
Skip to first unread message
Message has been deleted

Alexander

unread,
Dec 8, 2009, 5:01:04 AM12/8/09
to google-we...@googlegroups.com
Tried eventPreventDefault?

2009/12/5 Rob Tanner <caspe...@gmail.com>
Hi,

I want to add short context specific help messages when users right-
click into a text box.  Figuring out what button the pressed on the
mouse is a near no-brainer, but how to disable the default browser
response is a puzzler.   I've figured out how to disable right clicks
all together using the native interface:

       public static native void disableContextMenu(Element e) /*-{
               e.oncontextmenu = function() { return false; };
               }-*/;

But then I don't see them either.  All I want is to disable the
default context menu so that I can roll my own.  Any ideas?

Thanks,
Rob

--

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-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.





--
Regards,
Alexander

Mohamed Mansour

unread,
Dec 8, 2009, 10:32:47 AM12/8/09
to Google Web Toolkit
Can't you just return false for oncontextmenu ?

On Dec 8, 5:01 am, Alexander <the.malk...@gmail.com> wrote:
> Tried eventPreventDefault?
>
> 2009/12/5 Rob Tanner <caspersg...@gmail.com>
>
>
>
>
>
> > Hi,
>
> > I want to add short context specific help messages when users right-
> > click into a text box.  Figuring out what button the pressed on the
> > mouse is a near no-brainer, but how to disable the default browser
> > response is a puzzler.   I've figured out how to disable right clicks
> > all together using the native interface:
>
> >        public static native void disableContextMenu(Element e) /*-{
> >                e.oncontextmenu = function() { return false; };
> >                }-*/;
>
> > But then I don't see them either.  All I want is to disable the
> > default context menu so that I can roll my own.  Any ideas?
>
> > Thanks,
> > Rob
>
> > --
>
> > 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-we...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsubs cr...@googlegroups.com>
> > .

Rob Tanner

unread,
Dec 8, 2009, 12:31:50 PM12/8/09
to Google Web Toolkit
Here's a little snippet that doesn't do what I hoped:

public static native void disableContextMenu(Element e) /*-{
e.oncontextmenu = function() { return false; };
}-*/;

And I call that method immediately before I add the minPanel to the
RootPanel:

DataManager.disableContextMenu(mainPanel.getElement());

Now, not only do I not see the default browser behavior, I don't see
right clicks at all. In my TextBox() I added the click handler. When
the handler gets triggered, I get the NativeEvent from the ClickEvent
(NativeEvent nevn = event.getNativeEvent()) in order to detect which
button, etc, and the right button is never caught.

-- Rob

Sorinel C

unread,
Dec 15, 2009, 5:17:07 PM12/15/09
to Google Web Toolkit
Here you have some solutions:
http://ui-programming.blogspot.com/2009/12/gxt-ext-gwt-how-can-i-disable-browsers.html

I hope they are good for you!

Cheers.
Reply all
Reply to author
Forward
0 new messages