Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>GWT has a concept of <em>sunk</em> events. All <em>sunk</em> events, but only those, are passed to a <a href="http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/google/gwt/user/client/EventListener.html" rel="noreferrer"><code>EventListener</code></a>'s <code>onBrowserEvent</code>.</p> <p>At the lowest level, you attach an <code>EventListener</code> to an <code>Element</code> using <a href="http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/google/gwt/user/client/DOM.html#setEventListener%28com.google.gwt.user.client.Element,%20com.google.gwt.user.client.EventListener%29" rel="noreferrer"><code>DOM.setEventListener</code></a> and <em>sink</em> events with <a href="http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/google/gwt/user/client/DOM.html#sinkEvents%28com.google.gwt.user.client.Element,%20int%29" rel="noreferrer"><code>DOM.sinkEvents</code></a> (or more recently <a href="http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/google/gwt/user/client/DOM.html#sinkBitlessEvent%28com.google.gwt.user.client.Element,%20java.lang.String%29" rel="noreferrer"><code>DOM.setBitlessEvents</code></a>). To avoid memory leaks (particularly –if not only– in old IEs), you have to make sure you set an <code>Element</code>'s <code>EventListener</code> to <code>null</code> before the page unloads.</p> <p>A <code>Widget</code> is an <code>EventListener</code> and handles a few of these things for you: it automatically calls <code>DOM.setEventListener</code> in its <code>onAttach</code> and <code>onDetach</code>, and it keeps track of <em>sunk</em> events: its <code>sinkEvents</code> is additive to make it easier to work with, and therefore has an <code>unsinkEvents</code> counterpart.</p> <p>Later on, in GWT 1.6, event handlers have been added, and <code>addDomHandler</code> (and more recently <code>addBitlessDomHandler</code>) automatically calls <code>sinkEvents</code> with the appropriate values (taken from the <code>DomEvent.Type</code> passed as argument); and to make all of this work, the default behavior of <code>onBrowserEvent</code> in widgets is to dispatch events to the registered handlers.</p> <p>The reason for these <em>bitless</em> variants is that events were originally referred to as <code>int</code> constants in a bitfield, but browsers have more and more events so GWT started to run out of bits. The <em>bitless</em> variants are only usable for browsers that do <em>not</em> leak, as widgets don't keep track of which events have been registered that way to unregister them from their <code>onDetach</code>, contrary to bit-based events.</p> <p>All these new <code>DomEvent</code>s (with their handlers) starting with GWT 1.6 are wrappers around a <code>NativeEvent</code>. There are two kinds of <code>GwtEvent</code>s: native ones (<code>DomEvent</code>s), which are dispatched by the browser, and <em>logical</em> ones which are dispatched by GWT itself and are not mapped to events at the DOM level. <code>addDomHandler</code> is only concerned about <code>DomEvent</code>s, aka <em>native events</em>.</p> <p>Wrapping up: when you exit a text field that you just modified, the browser dispatches a <code>change</code> event. If the <code>TextBox</code> widget has <em>sunk</em> that event, its <code>onBrowserEvent</code> will be called with an <code>Event</code> (which is just a legacy subclass of <code>NativeEvent</code>) representing that event. The default implementation of <code>onBrowserEvent</code> then creates a <code>ChangeEvent</code> and dispatches it to the registered <code>ChangeHandler</code>s.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload