It appears that the oncontextmenu event won't get previewed correctly in all
circumstances. I've entered issue 2895 to this effect.
If the code you mention above is no longer working, it is probably because
the oncontextmenu property is being overwritten by sinkEvents(). Try moving
it to after sinkEvents() is called on the element -- I believe that should
work for now.

On Wed, Sep 17, 2008 at 8:18 AM, melody <[EMAIL PROTECTED]> wrote:

> Joel,
>
> The code you suggested is exactly what I have and have had since GWT
> 1.3.
>
> With the advent of GWT1.5, this nolonger works.
>
> Is there anything else I need to do to make the oncontextmenu event
> work in GWT 1.5.
>
> Also I noticed that now we have Event.ONCONTEXTMENU as an event bit.
>
> I tried using EventPreview to stop the context menu from showing but
> most of the times this event is NOT PREVIEWED! See example below
>
> <code>
>  public boolean onEventPreview(Event event) {
>            int type = DOM.eventGetType(event);
>            switch (type) {
>                case Event.ONCONTEXTMENU:
>                    Element target = DOM.eventGetTarget(event);
>                    if (!
> m_search_textbox.getElement().isOrHasChild(target)) {
>                        DOM.eventPreventDefault(event);
>                        DOM.eventCancelBubble(event, true);
>                        return false;//dont allow to bubble break;
>                    }
>                    break;
>            }
>      return true;
> }
> </code>
>
> Any reason why it previews sometimes and not all the time.
>
> Does it have anything to do with this line
>
> "GWT Widgets now sink their events lazily: widgets no longer routinely
> sink their events eagerly. Instead, the event is sunk the first time a
> listener is added to the widget. So subclasses which relied on eagerly
> sunk events will now have to manually sink the events they depend
> upon."
>
> from the breaking changes page:-
>
>
> http://code.google.com/docreader/#p=google-web-toolkit-doc-1-5&s=google-web-toolkit-doc-1-5&t=ReleaseNotes_1_5_BreakingChanges
>
>
> If so what do I need to do.
>
> Thanks,
>
> Melody
>
>
> On Jun 20 2006, 11:41 am, "Joel Webber" <[EMAIL PROTECTED]> wrote:
> > All,
> >
> > The document.oncontextmenu event is indeed what you're looking for.
>  Support
> > for it is fairly widespread (minus Opera 8, apparently).
> >
> > QuirksMode's description:
> http://www.quirksmode.org/js/events_compinfo.html#interface
> >
> > Try the following code:
> >
> >   private static native void killContextMenu() /*-{
> >     $doc.oncontextmenu = function() { return false; };
> >   }-*/;
> >
> > joel.
> >
> > On 6/7/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > I don't have any experience with GWT specifically, but when I needed
> > > this functionality in the past I found that there is a "contextmenu"
> > > event that can be bludgeoned into working across browsers.
> > > Specifically, you at least need to call event.stopPropagation() (if it
> > > exists) or some browsers will go ahead and show their context menu
> > > anyway.
> >
> > > I don't believe it's possible to do this solely with mouse events, but
> > > I could be mistaken.
> >
> > > [EMAIL PROTECTED] wrote:
> > > > Does anyone have any how-to on making a context (right-click) menu on
> a
> > > > GWT widget?
> >
> > > >  public class ContextButton extends Button implements EventListener {
> > > >         public void onBrowserEvent(Event event) {
> > > >             System.out.println(DOM.eventGetButton(event));
> > > >             System.out.println(DOM.eventGetClientX(event));
> > > >             System.out.println(DOM.eventGetClientY(event));
> > > >         }
> > > >     }
> >
> > > >   I'm unsure if the above is behaving correctly (for me to capture
> the
> > > > event), since my left button click actsas I would expect (if
> > > > Event.LEFT_BUTTON == 0) but I don't have a middle mouse button and
> the
> > > > browser context menu captures my right click...
> >
> > > > Any help would be appreciated.  Thanks.
>

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to