@Override
 public void onBrowserEvent(
     Context context,
     Element parent,
     String value,
     NativeEvent event,
     ValueUpdater<String> valueUpdater) {
   Object key = context.getKey();
   ViewData viewData = getViewData(key);
   if (viewData != null && viewData.isEditing()) {
     // Handle the edit event.
     editEvent(context, parent, value, viewData, event, valueUpdater);
   } else {
     String type = event.getType();
     int keyCode = event.getKeyCode();
     boolean enterPressed = KEYUP.equals(type) && keyCode == KeyCodes.KEY_ENTER;
     if (CLICK.equals(type) || enterPressed) {
       // Go into edit mode.
       if (viewData == null) {
         viewData = new ViewData(value);
         setViewData(key, viewData);
       } else {
         viewData.setEditing(true);
       }
       edit(context, parent, value);
     }
   }
 }
示例#2
0
 @Override
 public void onBrowserEvent(
     Context context, Element parent, C value, NativeEvent event, ValueUpdater<C> valueUpdater) {
   super.onBrowserEvent(context, parent, value, event, valueUpdater);
   if (CLICK.equals(event.getType())) {
     EventTarget eventTarget = event.getEventTarget();
     if (!Element.is(eventTarget)) {
       return;
     }
     if (parent.getFirstChildElement().isOrHasChild(Element.as(eventTarget))) {
       // Ignore clicks that occur outside of the main element.
       onEnterKeyDown(context, parent, value, event, valueUpdater);
     }
   }
 }