Package com.sencha.gxt.widget.core.client.event

Examples of com.sencha.gxt.widget.core.client.event.XEvent


    }
    if (isLocked()) {
      return;
    }

    XEvent xe = event.getEvent().<XEvent> cast();

    int rowIndex = event.getRowIndex();
    int colIndex = event.getColumnIndex();
    if (rowIndex == -1) {
      deselectAll();
      return;
    }
    if (selectionMode == SelectionMode.MULTI) {
      M sel = listStore.get(rowIndex);
      if (xe.getCtrlOrMetaKey() && isSelected(sel)) {
        doDeselect(Collections.singletonList(sel), false);
      } else if (xe.getCtrlOrMetaKey()) {
        grid.getView().focusCell(rowIndex, colIndex, false);
        doSelect(Collections.singletonList(sel), true, false);
      } else if (isSelected(sel) && !event.getEvent().getShiftKey() && !xe.getCtrlOrMetaKey() && selected.size() > 1) {
        grid.getView().focusCell(rowIndex, colIndex, false);
        doSelect(Collections.singletonList(sel), false, false);
      }
    }
View Full Code Here


    int colIndex = event.getColumnIndex();
    if (rowIndex == -1) {
      return;
    }

    XEvent e = event.getEvent().<XEvent> cast();

    if (event.getEvent().getButton() == Event.BUTTON_RIGHT) {
      if (selectionMode != SelectionMode.SINGLE && isSelected(listStore.get(rowIndex))) {
        return;
      }
      grid.getView().focusCell(rowIndex, colIndex, false);
      select(rowIndex, false);
    } else {
      M sel = listStore.get(rowIndex);
      if (selectionMode == SelectionMode.SIMPLE) {
        if (!isSelected(sel)) {
          grid.getView().focusCell(rowIndex, colIndex, false);
          select(sel, true);
        }

      } else if (selectionMode == SelectionMode.SINGLE) {
        if (e.getCtrlOrMetaKey() && isSelected(sel)) {
          deselect(sel);
        } else if (!isSelected(sel)) {
          grid.getView().focusCell(rowIndex, colIndex, false);
          select(sel, false);
        }
      } else if (!e.getCtrlOrMetaKey()) {
        if (event.getEvent().getShiftKey() && lastSelected != null) {
          int last = listStore.indexOf(lastSelected);
          int index = rowIndex;
          grid.getView().focusCell(index, colIndex, false);
          select(last, index, e.getCtrlOrMetaKey());
        } else if (!isSelected(sel)) {
          grid.getView().focusCell(rowIndex, colIndex, false);
          doSelect(Collections.singletonList(sel), false, false);
        }
      }
View Full Code Here

   * Handles a key down event (e.g. as fired by the key navigator).
   *
   * @param ne the key down event
   */
  protected void onKeyDown(NativeEvent ne) {
    XEvent e = ne.<XEvent> cast();
    if (Element.is(ne.getEventTarget())
        && !grid.getView().isSelectableTarget(Element.as(ne.getEventTarget()))) {
      return;
    }
    if (!e.getCtrlOrMetaKey() && selected.size() == 0 && getLastFocused() == null) {
      select(0, false);
    } else {
      int idx = listStore.indexOf(getLastFocused());
      if (idx >= 0 && (idx + 1) < listStore.size()) {
        if (e.getCtrlOrMetaKey() || (e.getShiftKey() && isSelected(listStore.get(idx + 1)))) {
          if (!e.getCtrlOrMetaKey()) {
            deselect(idx);
          }

          M lF = listStore.get(idx + 1);
          if (lF != null) {
            setLastFocused(lF);
            grid.getView().focusCell(idx + 1, 0, false);
          }

        } else {
          if (e.getShiftKey() && lastSelected != getLastFocused()) {
            grid.getView().focusCell(idx + 1, 0, false);
            select(listStore.indexOf(lastSelected), idx + 1, true);
          } else {
            if (idx + 1 < listStore.size()) {
              grid.getView().focusCell(idx + 1, 0, false);
              selectNext(e.getShiftKey());
            }
          }
        }
      }
    }

    e.preventDefault();
  }
View Full Code Here

      return;
    }
       
    int kc = ne.getKeyCode();

    XEvent e = ne.<XEvent> cast();

    if (lastSelected != null && enableNavKeys) {
      if (kc == KeyCodes.KEY_PAGEUP) {
        e.stopPropagation();
        e.preventDefault();
        select(0, false);
        grid.getView().focusRow(0);
      } else if (kc == KeyCodes.KEY_PAGEDOWN) {
        e.stopPropagation();
        e.preventDefault();
        int idx = listStore.indexOf(listStore.get(listStore.size() - 1));
        select(idx, false);
        grid.getView().focusRow(idx);
      }
    }
    // if space bar is pressed
    if (e.getKeyCode() == 32) {
      if (getLastFocused() != null) {
        if (e.getShiftKey() && lastSelected != null) {
          int last = listStore.indexOf(lastSelected);
          int i = listStore.indexOf(getLastFocused());
          grid.getView().focusCell(i, 0, false);
          select(last, i, e.getCtrlOrMetaKey());
        } else {
          if (isSelected(getLastFocused())) {
            deselect(getLastFocused());
          } else {
            grid.getView().focusCell(listStore.indexOf(getLastFocused()), 0, false);
View Full Code Here

   * Handles a key up event (e.g. as fired by the key navigator).
   *
   * @param e the key up event
   */
  protected void onKeyUp(NativeEvent e) {
    XEvent xe = e.<XEvent> cast();
    if (Element.is(e.getEventTarget())
        && !grid.getView().isSelectableTarget(Element.as(e.getEventTarget()))) {
      return;
    }
    int idx = listStore.indexOf(getLastFocused());
    if (idx >= 1) {
      if (xe.getCtrlOrMetaKey() || (e.getShiftKey() && isSelected(listStore.get(idx - 1)))) {
        if (!xe.getCtrlOrMetaKey()) {
          deselect(idx);
        }

        M lF = listStore.get(idx - 1);
        if (lF != null) {
View Full Code Here

      setValue(activeDate.getFirstDayOfMonth().asDate(), false);
    }
  }

  protected void onKeyLeft(NativeEvent evt) {
    XEvent e = evt.cast();
    e.stopEvent();
    if (e.getCtrlOrMetaKey()) {
      showPrevMonth();
    } else {
      setValue(activeDate.addDays(-1).asDate(), false);
    }
  }
View Full Code Here

      setValue(activeDate.addMonths(-1).asDate(), false);
    }
  }

  protected void onKeyRight(NativeEvent evt) {
    XEvent e = evt.cast();
    e.stopEvent();
    if (e.getCtrlOrMetaKey()) {
      showNextMonth();
    } else {
      setValue(activeDate.addDays(1).asDate(), false);
    }
  }
View Full Code Here

      setValue(activeDate.addDays(1).asDate(), false);
    }
  }

  protected void onKeyUp(NativeEvent evt) {
    XEvent e = evt.cast();
    e.stopEvent();
    if (e.getCtrlOrMetaKey()) {
      showNextYear();
    } else {
      setValue(activeDate.addDays(-7).asDate(), false);
    }
  }
View Full Code Here

  public void setVertical(boolean isVertical) {
    this.isVertical = isVertical;
  }

  protected void handleMouseClick(ClickEvent ce) {
    XEvent e = ce.getNativeEvent().<XEvent> cast();
    XElement target = e.getEventTargetEl();
    int index = listView.findElementIndex(target);

    if (isLocked() || isInput(target)) {
      return;
    }
    if (index == -1) {
      deselectAll();
      return;
    }
    if (selectionMode == SelectionMode.MULTI) {
      M sel = listStore.get(index);
      if (e.getCtrlOrMetaKey() && isSelected(sel)) {
        doDeselect(Collections.singletonList(sel), false);
      } else if (e.getCtrlOrMetaKey()) {
        doSelect(Collections.singletonList(sel), true, false);
        listView.focusItem(index);
      } else if (isSelected(sel) && !e.getShiftKey() && !e.getCtrlOrMetaKey() && selected.size() > 1) {
        doSelect(Collections.singletonList(sel), false, false);
        listView.focusItem(index);
      }
    }
View Full Code Here

    }

  }

  protected void handleMouseDown(MouseDownEvent mde) {
    XEvent e = mde.getNativeEvent().<XEvent> cast();
    XElement target = e.getEventTargetEl();
    int index = listView.findElementIndex(target);

    if (index == -1 || isLocked() || isInput(target)) {
      return;
    }
    if (e.isRightClick()) {
      if (selectionMode != SelectionMode.SINGLE && isSelected(listStore.get(index))) {
        return;
      }
      select(index, false);
      listView.focusItem(index);
    } else {
      M sel = listStore.get(index);
      if (selectionMode == SelectionMode.SIMPLE) {
        if (!isSelected(sel)) {
          listView.focusItem(index);
          select(sel, true);
        }

      } else if (selectionMode == SelectionMode.SINGLE) {
        if (e.getCtrlOrMetaKey() && isSelected(sel)) {
          deselect(sel);
        } else if (!isSelected(sel)) {
          listView.focusItem(index);
          select(sel, false);
        }
      } else if (!e.getCtrlOrMetaKey()) {
        if (e.getShiftKey() && lastSelected != null) {
          int last = listStore.indexOf(lastSelected);
          listView.focusItem(last);
          select(last, index, e.getCtrlOrMetaKey());

        } else if (!isSelected(sel)) {
          listView.focusItem(index);
          doSelect(Collections.singletonList(sel), false, false);
        }
View Full Code Here

TOP

Related Classes of com.sencha.gxt.widget.core.client.event.XEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.