Wednesday, March 6, 2019

Re: Enter key to change the focus from one TextInputCell to another in a celltable.

You are a STAR Stefaan!! Thank you so much. After adding validation to the inputCell it was a real problem to get the tabbing sorted again. Thank you!

On Friday, September 21, 2012 at 11:11:10 PM UTC+2, Stefaan Vanderheyden wrote:
Sorry, I forgot to mention:

You get the currentRow from the index value provided in the field updater and the currentCol by querying the celltable for the updated column's index (cellTable.getColumnIndex(updatedCol))...

On Friday, September 21, 2012 11:09:08 PM UTC+2, Stefaan Vanderheyden wrote:
Here is some code you might also find applicable to your use case:

    private void focusOnNext(final int currentRow, final int currentCol) {
        // Scan remaining cells in table for a form element to focus on.
        for (int r = currentRow; r < this.pricingTable.getRowCount(); r++) {
            final NodeList<TableCellElement> rowCells =
                    this.pricingTable.getRowElement(r).getCells();
            for (int c = 0; c < rowCells.getLength(); c++) {
                if ((r == currentRow) && (c <= currentCol)) {
                    // don't process these cells since we would be moving the
                    // focus backwards!
                } else {
                    if (rowCells.getItem(c).getElementsByTagName("input")
                            .getItem(0) != null) {
                        rowCells.getItem(c).getElementsByTagName("input")
                                .getItem(0).focus();
                        return;
                    }
                    if (rowCells.getItem(c).getElementsByTagName("select")
                            .getItem(0) != null) {
                        rowCells.getItem(c).getElementsByTagName("select")
                                .getItem(0).focus();
                        return;
                    }
                    if (rowCells.getItem(c).getElementsByTagName("textarea")
                            .getItem(0) != null) {
                        rowCells.getItem(c).getElementsByTagName("textarea")
                                .getItem(0).focus();
                        return;
                    }
                }
            }
        }
    }

I call this method in my FieldUpdater after redrawing the row on a value change.  It works very nicely!

On Wednesday, July 25, 2012 11:26:04 AM UTC+2, Nitin wrote:

In the cell table to have tab flow working, I had to do the following: cellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);

apart from changing the template of TextInputcell. This helped me in getting the tab flow working properly i.e. when I hit TAB the focus shifts to the next editable cell of the celltable.

But there is one more requirement in my project which says that the enter key should behave as the tab key and hence when we hit enter on a particular TextInputcell, the focus should move to the next TextInputcell of the celltable. Can anyone please help me with this?

I have tried lots of things to achieve this, but none is working. This is very urgent for the project. Please let me know, if you need more information on the issue.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment