Hi all,

I'm trying to build a CellTable with editable text fields in such a
way that when the user presses the enter key in such a text field, the
focus is given to the cell in the next column. To this end, I have
subclassed EditTextCell in MyEditTextCell and overridden the
onBrowserEvent method as follows:

@Override
public void onBrowserEvent(Context context, Element parent, String
value, NativeEvent event, ValueUpdater<String> valueUpdater) {
        super.onBrowserEvent(context, parent, value, event, valueUpdater);

                if ("keyup".equals(event.getType()) && event.getKeyCode() ==
KeyCodes.KEY_ENTER) {
                        myHandler.handleEnterKeyUp(context);
                }
}

The handler code is as follows:

public void handleEnterKeyUp(final Context context) {
        Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {

        @Override
        public void execute() {
                // Click the next cell.
                int row =
dataProvider.getList().indexOf(selectionModel.getSelectedObject());
                int column = context.getColumn() + 1;

                NativeEvent clickEvent =
Document.get().createClickEvent(1, 0, 0, 0, 0, false, false, false,
false);
 
cellTable.getRowElement(row).getCells().getItem(column).dispatchEvent(clickEvent);
            }
        });
}

This works fine in case the next cell is again a MyEditTextCell, but
my table also contains a column with list boxes (SelectionCells), and
these never seem to receive the click event. I would expect the list
box to open and get focus, since that is what happens when I click it
with the mouse.

I realize this is a rather cumbersome way to bring about the desired
functionality, but regardless, I fail to see why it's not working. If
I should indeed approach the problem differently altogether, then by
all means let me know. I should add that setting focus to the desired
element as follows does not work at all (i.e. also the MyEditTextCells
do not receive focus, which with the code above does work):

cellTable.getRowElement(row).getCells().getItem(column).focus();

Again, I do not see why. Any help would be greatly appreciated.

Thanks,
Ralf

-- 
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.

Reply via email to