Javascript – How do I check if an event can be canceled from my GWT code?

How do I check if an event can be canceled from my GWT code?… here is a solution to the problem.

How do I check if an event can be canceled from my GWT code?

Javascript events have a “cancelable” property

How do I access this property from my GWT code? It is not exported in GWT Event or NativeEvent class.

Solution

You can use JSNI:

  public native boolean eventIsCancelable(NativeEvent evt) /*-{
    return typeof evt.cancelable !== 'boolean' || evt.cancelable;
  }-*/;

Anyway, a phone call is being made

event.preventDefault();
event.stopPropagation();

Isn’t it enough?

Related Problems and Solutions