This will work:

        @Override
        public void onFocus(FocusEvent event) {
                TextBox tb = (TextBox) event.getSource();
                Element td =  DOM.getParent(tb.getElement());
                Element tr = DOM.getParent(td);
                Element body = DOM.getParent(tr);
                int row = DOM.getChildIndex(body, tr);
                System.out.println("=" + row + " " + tb.getText());
        }


On 8 apr, 11:16, Bonor <[email protected]> wrote:
> Hello Robert,
> Thanks for the reply. Actually I was hoping for a 'shorter' way to
> determine the current row with a trick via DOM. Of course, your
> solution will work, but I was wondering if there is a way in DOM to do
> this; something like:
>
>         @Override
>         public void onFocus(FocusEvent event) {
>                 TextBox tb = (TextBox) event.getSource();
>                 Element td = tb.getParent().getElement();
>                 Element tr = DOM.getParent(td);
>                 Element body = DOM.getParent(tr);
>                 int row = DOM.getChildIndex(body, tr);
>
>                 System.out.println("=" + row+"  "+tb.getText());
>         }
>
> ...FlexTable implements FocusHandler and with every
> textbox.getTextBox().addFocusHandler(this);
>
> Note that this snippet DOESN'T work.
>
> On 8 apr, 08:00, rjcarr <[email protected]> wrote:
>
>
>
> > Hi Bonor-
>
> > Here's a quick algorithm.  I'm sure it isn't complete so fill in the
> > gaps as necessary:
>
> >  1) Extend the TextBox type so it knows what row of the table it is
> > being added to.
> >  2) Create a FlexTable and add your TextBoxes to it, passing it the
> > current row of the table.  Be sure to add a focus handler to the
> > TextBoxes as well.
> >  3) When the focus is fired for that text box, acquire its row number,
> > and then change the CSS for that row (e.g.,
> > table.getRowFormatter().setStyleName()).
>
> > That should be it.  Good luck!
>
> > On Apr 7, 6:04 am, Bonor <[email protected]> wrote:
>
> > > I want to highlight the current row in a FlexTable (the cells contain
> > > TextBoxes).
> > > If a user tabs through the cells, how can I highlight the current row?
> > > Thanks in advanced

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

Reply via email to