John
John

Reputation: 857

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

Upvotes: 7

Views: 4407

Answers (2)

t&#246;rzsm&#243;kus
t&#246;rzsm&#243;kus

Reputation: 2003

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

Upvotes: 3

Jason Terk
Jason Terk

Reputation: 6025

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

Upvotes: 4

Related Questions