Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the list of valid GWT DOM / consumed events for Cells?

I've run into this multiple times, and can't find anything comprehensive. I want to know the complete list of all valid consumable DOM events for GWT.

The GWT docs for NativeEvent says:

public final java.lang.String getType()
Gets the enumerated type of this event.
Returns:
the event's enumerated type

Where is this enumeration? Does it actually exist? The actual code used (that I've found) that explicitly says these events always uses strings: "click", "contextmenu", "mouseup", "dblclick", etc. (etc covers so many vaguaries ...)

I'm trying to implement both Double Click and Right Click for cells in a CellTable ala this post. I'm passing super("click", "contextmenu", "mouseup", "dblclick"); in the constructor of my extension of AbstractCell. Then I overrode onBrowserEvent:

@Override

    public void onBrowserEvent(Context context, Element parent, ImageProperties<T> value,
            NativeEvent event, ValueUpdater<ImageProperties<T>> valueUpdater) {
        if (event.getButton() == NativeEvent.BUTTON_RIGHT) {
            event.stopPropagation();
            event.preventDefault();
            eventBus.fireEvent(new RightClickEvent<Context>(context, event));
        } else {
            super.onBrowserEvent(context, parent, value, event, valueUpdater);
        }
    }

However, I run into two issues. One, the default contextMenu still gets shown (over my custom one) - not to mention it doesn't even use the DOM event type. A different problem, how do I check if its a double click event? I find it hard to believe that it's literally an arbitrary set of strings ...

Thanks in advance! John

like image 647
John Avatar asked Mar 03 '11 18:03

John


2 Answers

Native JavaScript DOM event types really are arbitrary strings and support for a given event type (and the name thereof) can be browser dependent.

like image 113
Jason Terk Avatar answered Oct 06 '22 23:10

Jason Terk


the enumeration you are looking for does exist in the BrowserEvents class. you should use those constants instead of “magic” string literals.

like image 26
törzsmókus Avatar answered Oct 06 '22 23:10

törzsmókus