1. #1
    Ext GWT Premium Member
    Join Date
    Aug 2009
    Location
    Kensington, MD
    Posts
    29
    Vote Rating
    0
    cpopp is on a distinguished road

      0  

    Default Strange behavior attaching Listener to a WidgetComponent

    Strange behavior attaching Listener to a WidgetComponent


    This is a continuation of previous post about turning an icon into a WidgetComponent.

    Here's the basic code setup:

    Code:
    WidgetComponent w = new WidgetComponent(myIcon);
    w.setToolTip("test");
    w.addListener(Events.OnMouseOver, new Listener<ComponentEvent>() {
       @Override
       public void handleEvent(ComponentEvent e) {
          EventType type = e.getType();
          if (type == Events.OnMouseOver) {
             //do stuff
          }
       }
    });
    This behaves as expected.

    The strange part is if I remove the w.setToolTip("test") line the other Listener stuff doesn't happen. For some reason the setToolTip() method correctly attaches a listener but just adding a Listener directly doesn't work.

    Is this a bug, or am I missing something.
    Software Developer
    Helm Point Solutions, Inc.

  2. #2
    Sencha User
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Its a bug yes, but in your code. When listening to browserevents you will need so sink the event you want to listen to.

    setToolTip is doing that because it needs the events.

    Code:
    w.sinkEvents(EVENT.ONMOUSEOVER);

  3. #3
    Ext GWT Premium Member
    Join Date
    Aug 2009
    Location
    Kensington, MD
    Posts
    29
    Vote Rating
    0
    cpopp is on a distinguished road

      0  

    Default


    That was the issue.

    I so enjoy making rookie mistakes.

    Thanks again sven.
    Software Developer
    Helm Point Solutions, Inc.

Thread Participants: 1