Re: How can I add a MouseOutHandler to a FlexTable cell?

2009-08-11 Thread lowecg2004

Based on Kelo's example above:

public class BocaJrsTable extends FlexTable implements
HasMouseOutHandlers {

// ... as above, but add the following:

public int[] getCellForEvent(final MouseEvent? event) {
final Element td = 
getEventTargetCell(Event.as(event.getNativeEvent
()));

if (td == null) {
return null;
}

final Element tr = DOM.getParent(td);
final Element body = DOM.getParent(tr);

final int r = DOM.getChildIndex(body, tr);
final int c = DOM.getChildIndex(tr, td);

final int[] idx = new int[] { r, c };

return idx;
}

}


someTable = new BocaJrsTable();


someTable.addMouseOverHandler(new MouseOverHandler() {

@Override
public void onMouseOver(final MouseOverEvent event) {
final int r = row(event);

...


}}
);



public static int row(final MouseEvent? event) {
// note that in general, events can have sources that are not
Widgets.
BocaJrsTable sender = (BocaJrsTable) event.getSource();

final int[] idx = sender.getCellForEvent(event);

if (idx == null) {
return -1;
}

return idx[0];
}

I hope that helps,.

Cheers,

C.


On Aug 8, 3:51 am, Wimpog wimpo...@gmail.com wrote:
 I would also like to know how to find out which row mouseEvent has
 occurred
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: How can I add a MouseOutHandler to a FlexTable cell?

2009-06-16 Thread Ravi

How to find out the row number on which mouseEvent has occured(in
Kelo's example)???

On Jun 13, 2:19 am, Kelo mcac...@gmail.com wrote:
 Hi Eduardo,

      Here's your solution:

 public class BocaJrsTable extends FlexTable implements
 HasMouseOutHandlers {

         private HandlerManager manager = new HandlerManager(this);

         public BocaJrsTable(){
                 super();
                 addDomHandler(new MouseOutHandler() {
                         @Override
                         public void onMouseOut(MouseOutEvent event) {
                                 fireEvent(event);
                         }
                 }, MouseOutEvent.getType());

         }

         @Override
         public HandlerRegistration addMouseOutHandler(MouseOutHandler
 handler) {
                 return manager.addHandler(MouseOutEvent.getType(), handler);
         }

         @Override
         public void fireEvent(GwtEvent? event) {
                 manager.fireEvent(event);
         }

 }

 Good luck !

 On Jun 12, 5:40 pm, Eduardo Nunes esnu...@gmail.com wrote:

  I already tried it, but it didn't work. I found a solution, but a very ugly 
  one:

      private class FlexTableTd extends UIObject implements 
  HasMouseOutHandlers,
              HasMouseOverHandlers, EventListener {

          public FlexTableTd(Element element) {
              this.setElement(element);
              DOM.setEventListener(this.getElement(), this);
          }

          public HandlerRegistration addMouseOutHandler(MouseOutHandler 
  handler) {
              this.sinkEvents(Event.ONMOUSEOUT);
              return
  ensureHandlers().addHandler(MouseOutEvent.getType(), handler);
          }

          public HandlerRegistration
  addMouseOverHandler(MouseOverHandler handler) {
              this.sinkEvents(Event.ONMOUSEOVER);
              return
  ensureHandlers().addHandler(MouseOverEvent.getType(), handler);
          }

          public void fireEvent(GwtEvent? event) {
              ensureHandlers().fireEvent(event);
          }

          public void onBrowserEvent(Event event) {
              switch (DOM.eventGetType(event)) {
                  case Event.ONMOUSEOVER:
                  case Event.ONMOUSEOUT:
                      Element related = event.getRelatedTarget();
                      if (related != null  
  getElement().isOrHasChild(related)) {
                          return;
                      }
                      break;
              }
              DomEvent.fireNativeEvent(event, this, this.getElement());
          }
          private HandlerManager handlerManager;

          HandlerManager ensureHandlers() {
              return handlerManager == null ? handlerManager = new
  HandlerManager(this)
                      : handlerManager;
          }
      }

  On Fri, Jun 12, 2009 at 4:46 PM, matthew jonesbigboxe...@gmail.com wrote:

   Try this instead.

   addMouseOverHandler(MouseOverHandler handler) {
              return addDomHandler(handler, MouseOverEvent.getType());
          }

   On Jun 12, 12:52 pm, Eduardo Nunes esnu...@gmail.com wrote:
   Well, the subject says everything, I would like to know how can I add
   a MouseOutHandler to a FlexTable cell. I tried a lot of things but
   none of them with success. I tried a wrap class:

       private class FlexTableTd extends Widget implements 
   HasMouseOutHandlers,
               HasMouseOverHandlers {

           public FlexTableTd(Element element) {
               setElement(element);
           }

           public HandlerRegistration addMouseOutHandler(MouseOutHandler 
   handler) {
               return addHandler(handler, MouseOutEvent.getType());
           }

           public HandlerRegistration
   addMouseOverHandler(MouseOverHandler handler) {
               return addHandler(handler, MouseOverEvent.getType());
           }
       }

   and I tried

   FlexTableTd td = new 
   FlexTableTd(table.getFlexCellFormatter().getElement(0, 0));
   td.addMouseOverHandler(...);

   but it doesn't work.

   --
   Eduardo S. Nuneshttp://e-nunes.com.br

  --
  Eduardo S. Nuneshttp://e-nunes.com.br
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: How can I add a MouseOutHandler to a FlexTable cell?

2009-06-15 Thread Dean S. Jones

Thanks for the example - I have to support 1.5 and 1.6 - so I am still
coding to the old event model...

But it's nice to see looking inside HandlerManager that they defer
editing of the handler list while the event it firing.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: How can I add a MouseOutHandler to a FlexTable cell?

2009-06-12 Thread matthew jones

Try this instead.

addMouseOverHandler(MouseOverHandler handler) {
return addDomHandler(handler, MouseOverEvent.getType());
}

On Jun 12, 12:52 pm, Eduardo Nunes esnu...@gmail.com wrote:
 Well, the subject says everything, I would like to know how can I add
 a MouseOutHandler to a FlexTable cell. I tried a lot of things but
 none of them with success. I tried a wrap class:

     private class FlexTableTd extends Widget implements HasMouseOutHandlers,
             HasMouseOverHandlers {

         public FlexTableTd(Element element) {
             setElement(element);
         }

         public HandlerRegistration addMouseOutHandler(MouseOutHandler 
 handler) {
             return addHandler(handler, MouseOutEvent.getType());
         }

         public HandlerRegistration
 addMouseOverHandler(MouseOverHandler handler) {
             return addHandler(handler, MouseOverEvent.getType());
         }
     }

 and I tried

 FlexTableTd td = new FlexTableTd(table.getFlexCellFormatter().getElement(0, 
 0));
 td.addMouseOverHandler(...);

 but it doesn't work.

 --
 Eduardo S. Nuneshttp://e-nunes.com.br

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: How can I add a MouseOutHandler to a FlexTable cell?

2009-06-12 Thread Eduardo Nunes

I already tried it, but it didn't work. I found a solution, but a very ugly one:

private class FlexTableTd extends UIObject implements HasMouseOutHandlers,
HasMouseOverHandlers, EventListener {

public FlexTableTd(Element element) {
this.setElement(element);
DOM.setEventListener(this.getElement(), this);
}

public HandlerRegistration addMouseOutHandler(MouseOutHandler handler) {
this.sinkEvents(Event.ONMOUSEOUT);
return
ensureHandlers().addHandler(MouseOutEvent.getType(), handler);
}

public HandlerRegistration
addMouseOverHandler(MouseOverHandler handler) {
this.sinkEvents(Event.ONMOUSEOVER);
return
ensureHandlers().addHandler(MouseOverEvent.getType(), handler);
}

public void fireEvent(GwtEvent? event) {
ensureHandlers().fireEvent(event);
}

public void onBrowserEvent(Event event) {
switch (DOM.eventGetType(event)) {
case Event.ONMOUSEOVER:
case Event.ONMOUSEOUT:
Element related = event.getRelatedTarget();
if (related != null  getElement().isOrHasChild(related)) {
return;
}
break;
}
DomEvent.fireNativeEvent(event, this, this.getElement());
}
private HandlerManager handlerManager;

HandlerManager ensureHandlers() {
return handlerManager == null ? handlerManager = new
HandlerManager(this)
: handlerManager;
}
}



On Fri, Jun 12, 2009 at 4:46 PM, matthew jonesbigboxe...@gmail.com wrote:

 Try this instead.

 addMouseOverHandler(MouseOverHandler handler) {
            return addDomHandler(handler, MouseOverEvent.getType());
        }

 On Jun 12, 12:52 pm, Eduardo Nunes esnu...@gmail.com wrote:
 Well, the subject says everything, I would like to know how can I add
 a MouseOutHandler to a FlexTable cell. I tried a lot of things but
 none of them with success. I tried a wrap class:

     private class FlexTableTd extends Widget implements HasMouseOutHandlers,
             HasMouseOverHandlers {

         public FlexTableTd(Element element) {
             setElement(element);
         }

         public HandlerRegistration addMouseOutHandler(MouseOutHandler 
 handler) {
             return addHandler(handler, MouseOutEvent.getType());
         }

         public HandlerRegistration
 addMouseOverHandler(MouseOverHandler handler) {
             return addHandler(handler, MouseOverEvent.getType());
         }
     }

 and I tried

 FlexTableTd td = new FlexTableTd(table.getFlexCellFormatter().getElement(0, 
 0));
 td.addMouseOverHandler(...);

 but it doesn't work.

 --
 Eduardo S. Nuneshttp://e-nunes.com.br

 




-- 
Eduardo S. Nunes
http://e-nunes.com.br

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: How can I add a MouseOutHandler to a FlexTable cell?

2009-06-12 Thread Kelo

Hi Eduardo,

 Here's your solution:

public class BocaJrsTable extends FlexTable implements
HasMouseOutHandlers {

private HandlerManager manager = new HandlerManager(this);

public BocaJrsTable(){
super();
addDomHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
fireEvent(event);
}
}, MouseOutEvent.getType());

}

@Override
public HandlerRegistration addMouseOutHandler(MouseOutHandler
handler) {
return manager.addHandler(MouseOutEvent.getType(), handler);
}


@Override
public void fireEvent(GwtEvent? event) {
manager.fireEvent(event);
}

}

Good luck !

On Jun 12, 5:40 pm, Eduardo Nunes esnu...@gmail.com wrote:
 I already tried it, but it didn't work. I found a solution, but a very ugly 
 one:

     private class FlexTableTd extends UIObject implements HasMouseOutHandlers,
             HasMouseOverHandlers, EventListener {

         public FlexTableTd(Element element) {
             this.setElement(element);
             DOM.setEventListener(this.getElement(), this);
         }

         public HandlerRegistration addMouseOutHandler(MouseOutHandler 
 handler) {
             this.sinkEvents(Event.ONMOUSEOUT);
             return
 ensureHandlers().addHandler(MouseOutEvent.getType(), handler);
         }

         public HandlerRegistration
 addMouseOverHandler(MouseOverHandler handler) {
             this.sinkEvents(Event.ONMOUSEOVER);
             return
 ensureHandlers().addHandler(MouseOverEvent.getType(), handler);
         }

         public void fireEvent(GwtEvent? event) {
             ensureHandlers().fireEvent(event);
         }

         public void onBrowserEvent(Event event) {
             switch (DOM.eventGetType(event)) {
                 case Event.ONMOUSEOVER:
                 case Event.ONMOUSEOUT:
                     Element related = event.getRelatedTarget();
                     if (related != null  
 getElement().isOrHasChild(related)) {
                         return;
                     }
                     break;
             }
             DomEvent.fireNativeEvent(event, this, this.getElement());
         }
         private HandlerManager handlerManager;

         HandlerManager ensureHandlers() {
             return handlerManager == null ? handlerManager = new
 HandlerManager(this)
                     : handlerManager;
         }
     }



 On Fri, Jun 12, 2009 at 4:46 PM, matthew jonesbigboxe...@gmail.com wrote:

  Try this instead.

  addMouseOverHandler(MouseOverHandler handler) {
             return addDomHandler(handler, MouseOverEvent.getType());
         }

  On Jun 12, 12:52 pm, Eduardo Nunes esnu...@gmail.com wrote:
  Well, the subject says everything, I would like to know how can I add
  a MouseOutHandler to a FlexTable cell. I tried a lot of things but
  none of them with success. I tried a wrap class:

      private class FlexTableTd extends Widget implements 
  HasMouseOutHandlers,
              HasMouseOverHandlers {

          public FlexTableTd(Element element) {
              setElement(element);
          }

          public HandlerRegistration addMouseOutHandler(MouseOutHandler 
  handler) {
              return addHandler(handler, MouseOutEvent.getType());
          }

          public HandlerRegistration
  addMouseOverHandler(MouseOverHandler handler) {
              return addHandler(handler, MouseOverEvent.getType());
          }
      }

  and I tried

  FlexTableTd td = new 
  FlexTableTd(table.getFlexCellFormatter().getElement(0, 0));
  td.addMouseOverHandler(...);

  but it doesn't work.

  --
  Eduardo S. Nuneshttp://e-nunes.com.br

 --
 Eduardo S. Nuneshttp://e-nunes.com.br
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---