Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You'd want to implement these interfaces in your class:</p> <ul> <li>HasMouseOverHandlers </li> <li>HasMouseOutHandlers</li> <li>MouseOverHandler</li> <li>MouseOutHandler</li> </ul> <p>MouseOverEvent is fired when the mouse enters the element, and MouseOutEvent is fired when it's no longer over.</p> <p><strong>HasMouseOverHandler</strong> is implemented like this:</p> <pre><code>public HandlerRegistration addMouseOverHandler(MouseOverHandler handler) { return addDomHandler(handler, MouseOverEvent.getType()); } </code></pre> <p><strong>HasMouseOutHandler</strong> is implemented like this: </p> <pre><code>public HandlerRegistration addMouseOutHandler(MouseOutHandler handler) { return addDomHandler(handler, MouseOutEvent.getType()); } </code></pre> <p>After that you just handle the events with a MouseOverHandler and MouseOutHandler, should be pretty straightforward after that.</p> <p>If you want to add an EventHandler to an Element that already exists in the HTML the only idea I've come up with is creating a wrapper class. <strong>This is completely untested.</strong></p> <pre><code>class ElementWrapper extends UIObject implements HasMouseOverHandlers, HasMouseOutHandlers { public ElementWrapper(Element theElement) { setElement(theElement); } public HandlerRegistration addMouseOutHandler(MouseOutHandler handler) { return addDomHandler(handler, MouseOutEvent.getType()); } public HandlerRegistration addMouseOverHandler(MouseOverHandler handler) { return addDomHandler(handler, MouseOverEvent.getType()); } } </code></pre> <p>Then you could get an existing Element from the HTML and initialize like this:</p> <pre><code>onModuleLoad() { Element theElement = RootPanel().get("elementID"); ElementWrapper wrapper = new ElementWrapper(theElement); wrapper.addMouseOverHandler(new myHandler()); } </code></pre> <p>Hope this helps.</p>
    singulars
    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. 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.
 

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