当前位置: 首页>>代码示例>>Java>>正文


Java Event.preventDefault方法代码示例

本文整理汇总了Java中elemental.events.Event.preventDefault方法的典型用法代码示例。如果您正苦于以下问题:Java Event.preventDefault方法的具体用法?Java Event.preventDefault怎么用?Java Event.preventDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在elemental.events.Event的用法示例。


在下文中一共展示了Event.preventDefault方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runActions

import elemental.events.Event; //导入方法依赖的package包/类
/**
 * Finds and runs an action cancelling original key event
 *
 * @param actionIds list containing action ids
 * @param keyEvent original key event
 */
private void runActions(List<String> actionIds, Event keyEvent) {
  for (String actionId : actionIds) {
    Action action = actionManager.getAction(actionId);
    if (action == null) {
      continue;
    }
    ActionEvent e = new ActionEvent(presentationFactory.getPresentation(action), actionManager);
    action.update(e);

    if (e.getPresentation().isEnabled() && e.getPresentation().isVisible()) {
      /** Stop handling the key event */
      keyEvent.preventDefault();
      keyEvent.stopPropagation();

      /** Perform the action */
      action.actionPerformed(e);
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:KeyBindingManager.java

示例2: handleEvent

import elemental.events.Event; //导入方法依赖的package包/类
@Override
public void handleEvent(final Event evt) {
  if (evt instanceof KeyboardEvent) {
    final KeyboardEvent keyEvent = (KeyboardEvent) evt;
    switch (keyEvent.getKeyCode()) {
      case KeyCodes.KEY_ESCAPE:
        Scheduler.get()
            .scheduleDeferred(
                new ScheduledCommand() {
                  @Override
                  public void execute() {
                    popupWidget.hide();
                  }
                });
        break;
      case KeyCodes.KEY_DOWN:
        focusNext();
        break;
      case KeyCodes.KEY_UP:
        focusPrevious();
        break;
      case KeyCodes.KEY_HOME:
        focusFirst();
        break;
      case KeyCodes.KEY_END:
        focusLast();
        break;
      case KeyCodes.KEY_ENTER:
        evt.preventDefault();
        evt.stopImmediatePropagation();
        validateItem();
        break;
      default:
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:37,代码来源:PopupKeyDownListener.java

示例3: handleEvent

import elemental.events.Event; //导入方法依赖的package包/类
@Override
public void handleEvent(Event evt) {
  if (Event.KEYDOWN.equalsIgnoreCase(evt.getType())) {
    final KeyboardEvent keyEvent = (KeyboardEvent) evt;
    switch (keyEvent.getKeyCode()) {
      case KeyCodes.KEY_ESCAPE:
        Scheduler.get().scheduleDeferred(this::hide);
        break;

      case KeyCodes.KEY_DOWN:
        selectNext();
        evt.preventDefault();
        break;

      case KeyCodes.KEY_UP:
        selectPrevious();
        evt.preventDefault();
        break;

      case KeyCodes.KEY_PAGEUP:
        selectPreviousPage();
        evt.preventDefault();
        break;

      case KeyCodes.KEY_PAGEDOWN:
        selectNextPage();
        evt.preventDefault();
        break;

      case KeyCodes.KEY_HOME:
        selectFirst();
        break;

      case KeyCodes.KEY_END:
        selectLast();
        break;

      case KeyCodes.KEY_ENTER:
        evt.preventDefault();
        evt.stopImmediatePropagation();
        validateItem(true);
        break;

      case KeyCodes.KEY_TAB:
        evt.preventDefault();
        evt.stopImmediatePropagation();
        validateItem(false);
        break;
    }
  } else if (Event.SCROLL.equalsIgnoreCase(evt.getType())) {
    updateIfNecessary();
  } else if (Event.FOCUS.equalsIgnoreCase(evt.getType())) {
    focused = true;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:56,代码来源:ContentAssistWidget.java

示例4: handleEvent

import elemental.events.Event; //导入方法依赖的package包/类
@Override
public void handleEvent(Event evt) {
  // Don't even bother to do anything unless we have someone ready to
  // handle events.
  if (getDelegate() == null
      || (primaryMouseButtonOnly
          && ((MouseEvent) evt).getButton() != MouseEvent.Button.PRIMARY)) {
    return;
  }

  Element eventTarget = (Element) evt.getTarget();

  if (CssUtils.containsClassName(eventTarget, css.expandControl())) {
    onExpansionControlEvent(evt, eventTarget);
  } else {
    Element treeNodeBody =
        CssUtils.getAncestorOrSelfWithClassName(eventTarget, css.treeNodeBody());
    if (treeNodeBody != null) {
      // this code emulate double click for tablets
      if (Event.MOUSEDOWN.equals(evt.getType())) {
        double currentClickMs = Duration.currentTimeMillis();
        if (currentClickMs - previousClickMs < MouseGestureListener.MAX_CLICK_TIMEOUT_MS
            && treeNodeBody.equals(previousClickTreeNodeBody)) {

          if (BrowserUtils.isAndroid() || BrowserUtils.isIPad() || BrowserUtils.isIphone()) {
            evt.stopPropagation();
            evt.preventDefault();
            doActionsForDoubleClick(treeNodeBody, evt);
          }
          return;
        } else {
          this.previousClickMs = currentClickMs;
          this.previousClickTreeNodeBody = treeNodeBody;
        }
      }

      onTreeNodeBodyChildEvent(evt, treeNodeBody);
    } else {
      onOtherEvent(evt);
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:43,代码来源:Tree.java

示例5: handleEvent

import elemental.events.Event; //导入方法依赖的package包/类
@Override
public void handleEvent(Event evt) {
  evt.stopPropagation();
  evt.preventDefault();
}
 
开发者ID:eclipse,项目名称:che,代码行数:6,代码来源:DomUtils.java

示例6: PopupWidget

import elemental.events.Event; //导入方法依赖的package包/类
public PopupWidget(final PopupResources popupResources, String title) {
  this.popupResources = popupResources;

  popupElement = Elements.createDivElement(popupResources.popupStyle().popup());

  Element headerElement = Elements.createDivElement(popupResources.popupStyle().header());
  headerElement.setInnerText(title);
  popupElement.appendChild(headerElement);

  popupBodyElement = Elements.createDivElement(popupResources.popupStyle().body());
  popupElement.appendChild(popupBodyElement);

  listElement = Elements.createUListElement();
  popupBodyElement.appendChild(listElement);

  popupListener =
      new EventListener() {
        @Override
        public void handleEvent(final Event evt) {
          if (evt instanceof MouseEvent) {
            final MouseEvent mouseEvent = (MouseEvent) evt;
            final EventTarget target = mouseEvent.getTarget();
            if (target instanceof Element) {
              final Element elementTarget = (Element) target;
              if (!PopupWidget.this.popupElement.contains(elementTarget)) {
                hide();
                evt.preventDefault();
              }
            }
          }
          // else won't happen
        }
      };

  keyboardListener = new PopupKeyDownListener(this, this.listElement);
}
 
开发者ID:eclipse,项目名称:che,代码行数:37,代码来源:PopupWidget.java


注:本文中的elemental.events.Event.preventDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。