com.google.gwt.event.dom.client.MouseEvent.getClientX()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中com.google.gwt.event.dom.client.MouseEvent.getClientX()方法的一些代码示例,展示了MouseEvent.getClientX()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MouseEvent.getClientX()方法的具体详情如下:
包路径:com.google.gwt.event.dom.client.MouseEvent
类名称:MouseEvent
方法名:getClientX

MouseEvent.getClientX介绍

[英]Gets the mouse x-position within the browser window's client area.
[中]获取浏览器窗口客户端区域内的鼠标x位置。

代码示例

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Gets the mouse x-position relative to the event's current target element.
 * 
 * @return the relative x-position
 */
public int getX() {
 Element relativeElem = getRelativeElement();
 if (relativeElem != null) {
  return getRelativeX(relativeElem);
 }
 return getClientX();
}

代码示例来源:origin: com.googlecode.gwt-test-utils/gwt-test-utils

@PatchMethod
static int getX(MouseEvent<?> event) {
  return event.getClientX();
}

代码示例来源:origin: gwt-test-utils/gwt-test-utils

@PatchMethod
static int getX(MouseEvent<?> event) {
  return event.getClientX();
}

代码示例来源:origin: net.wetheinter/gwt-user

/**
 * Gets the mouse x-position relative to the event's current target element.
 * 
 * @return the relative x-position
 */
public int getX() {
 Element relativeElem = getRelativeElement();
 if (relativeElem != null) {
  return getRelativeX(relativeElem);
 }
 return getClientX();
}

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

/**
 * Gets the mouse x-position relative to the event's current target element.
 * 
 * @return the relative x-position
 */
public int getX() {
 Element relativeElem = getRelativeElement();
 if (relativeElem != null) {
  return getRelativeX(relativeElem);
 }
 return getClientX();
}

代码示例来源:origin: usnistgov/iheos-toolkit2

private void showTooltip(MouseEvent<? extends EventHandler> e, List<String> text, int milliseconds) {
  tooltip.show(e.getClientX() + 20, e.getClientY() + 30, text, milliseconds);
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-lienzo

private void registerClickHandler() {
  HandlerRegistration registration = text.addNodeMouseClickHandler(event -> {
    if (null != textClickEventViewHandler) {
      eventHandlerManager.get().skipClickHandler();
      final TextClickEvent e = new TextClickEvent(event.getX(),
                            event.getY(),
                            event.getMouseEvent().getClientX(),
                            event.getMouseEvent().getClientY());
      textClickEventViewHandler.handle(e);
      eventHandlerManager.get().restoreClickHandler();
    }
  });
  eventHandlerManager.get().addHandlersRegistration(ViewEventType.TEXT_CLICK,
                           registration);
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-lienzo

private void registerDoubleClickHandler() {
  HandlerRegistration registration = text.addNodeMouseDoubleClickHandler(event -> {
    if (null != textDblClickEventViewHandler) {
      eventHandlerManager.get().skipClickHandler();
      final TextDoubleClickEvent e = new TextDoubleClickEvent(event.getX(),
                                  event.getY(),
                                  event.getMouseEvent().getClientX(),
                                  event.getMouseEvent().getClientY());
      textDblClickEventViewHandler.handle(e);
      eventHandlerManager.get().restoreClickHandler();
    }
  });
  eventHandlerManager.get().addHandlersRegistration(ViewEventType.TEXT_DBL_CLICK,
                           registration);
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-lienzo

private void registerTextExitHandler() {
  HandlerRegistration registration = text.addNodeMouseExitHandler(event -> {
    if (null != textOutEventViewHandler && hasText()) {
      final TextExitEvent textOutEvent = new TextExitEvent(event.getX(),
                                 event.getY(),
                                 event.getMouseEvent().getClientX(),
                                 event.getMouseEvent().getClientY());
      textOutEventViewHandler.handle(textOutEvent);
    }
  });
  eventHandlerManager.get().addHandlersRegistration(ViewEventType.TEXT_EXIT,
                           registration);
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-lienzo

private void registerTextEnterHandler() {
  HandlerRegistration registration = text.addNodeMouseEnterHandler(event -> {
    if (null != textOverHandlerViewHandler && hasText()) {
      final TextEnterEvent textOverEvent = new TextEnterEvent(event.getX(),
                                  event.getY(),
                                  event.getMouseEvent().getClientX(),
                                  event.getMouseEvent().getClientY());
      textOverHandlerViewHandler.handle(textOverEvent);
    }
  });
  eventHandlerManager.get().addHandlersRegistration(ViewEventType.TEXT_ENTER,
                           registration);
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-lienzo

protected HandlerRegistration[] registerExitHandler(final ViewHandler<ViewEvent> eventHandler) {
  return new HandlerRegistration[]{
      shape.addNodeMouseExitHandler(e -> {
        if (isEnabled()) {
          final MouseExitEvent event = new MouseExitEvent(e.getX(),
                                  e.getY(),
                                  e.getMouseEvent().getClientX(),
                                  e.getMouseEvent().getClientY());
          event.setShiftKeyDown(e.isShiftKeyDown());
          event.setAltKeyDown(e.isAltKeyDown());
          event.setMetaKeyDown(e.isMetaKeyDown());
          eventHandler.handle(event);
        }
      })
  };
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-lienzo

protected HandlerRegistration[] registerEnterHandler(final ViewHandler<ViewEvent> eventHandler) {
  return new HandlerRegistration[]{
      shape.addNodeMouseEnterHandler(e -> {
        if (isEnabled()) {
          final MouseEnterEvent event = new MouseEnterEvent(e.getX(),
                                   e.getY(),
                                   e.getMouseEvent().getClientX(),
                                   e.getMouseEvent().getClientY());
          event.setShiftKeyDown(e.isShiftKeyDown());
          event.setAltKeyDown(e.isAltKeyDown());
          event.setMetaKeyDown(e.isMetaKeyDown());
          eventHandler.handle(event);
        }
      })
  };
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-lienzo

@Override
public V addButton(Glyph glyph,
          String title,
          Consumer<MouseClickEvent> clickEventConsumer) {
  final ButtonItem button =
      toolboxFactory.buttons()
          .button(renderGlyph(glyph,
                    getGlyphSize()))
          .decorate(createDecorator())
          .tooltip(tooltip.createItem(title))
          .onMouseEnter(event -> onMouseEnter())
          .onMouseExit(event -> onMouseExit())
          .onClick(event -> clickEventConsumer.accept(new MouseClickEvent(event.getX(),
                                          event.getY(),
                                          event.getMouseEvent()
                                              .getClientX(),
                                          event.getMouseEvent()
                                              .getClientY())));
  addButton(button);
  return cast();
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-lienzo

protected HandlerRegistration[] registerTextDoubleClickHandler(final ViewHandler<ViewEvent> eventHandler) {
  return new HandlerRegistration[]{
      node.addNodeMouseDoubleClickHandler(nodeMouseDoubleClickEvent -> {
        if (isEnabled()) {
          skipClickHandler();
          final TextDoubleClickEvent event = new TextDoubleClickEvent(nodeMouseDoubleClickEvent.getX(),
                                        nodeMouseDoubleClickEvent.getY(),
                                        nodeMouseDoubleClickEvent.getMouseEvent().getClientX(),
                                        nodeMouseDoubleClickEvent.getMouseEvent().getClientY());
          event.setShiftKeyDown(nodeMouseDoubleClickEvent.isShiftKeyDown());
          event.setAltKeyDown(nodeMouseDoubleClickEvent.isAltKeyDown());
          event.setMetaKeyDown(nodeMouseDoubleClickEvent.isMetaKeyDown());
          eventHandler.handle(event);
          restoreClickHandler();
        }
      })
  };
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-lienzo-extensions

public IPrimitive<?> build(final IPrimitive<?> item,
              final double width,
              final double height) {
  decorator = createRectangle(width,
                height);
  this.add(decorator);
  this.add(item);
  decorator.setX(item.getX() - (padding / 4));
  decorator.setY(item.getY() - (padding / 4));
  decorator.addNodeMouseEnterHandler(nodeMouseEnterEvent -> show(nodeMouseEnterEvent.getMouseEvent().getClientX(),
                                  nodeMouseEnterEvent.getMouseEvent().getClientY()));
  decorator.addNodeMouseExitHandler(nodeMouseExitEvent -> hide());
  decorator.addNodeMouseMoveHandler(nodeMouseMoveEvent -> timer.cancel());
  item.setDraggable(false);
  decorator.setDraggable(false).moveToTop();
  return this;
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-lienzo

final int x = nodeMouseClickEvent.getX();
final int y = nodeMouseClickEvent.getY();
final int clientX = nodeMouseClickEvent.getMouseEvent().getClientX();
final int clientY = nodeMouseClickEvent.getMouseEvent().getClientY();
final boolean isShiftKeyDown = nodeMouseClickEvent.isShiftKeyDown();

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-lienzo

protected HandlerRegistration[] registerDoubleClickHandler(final ViewHandler<ViewEvent> eventHandler) {
  return new HandlerRegistration[]{
      node.addNodeMouseDoubleClickHandler(nodeMouseDoubleClickEvent -> {
        if (isEnabled()) {
          skipClickHandler();
          final MouseDoubleClickEvent event = new MouseDoubleClickEvent(nodeMouseDoubleClickEvent.getX(),
                                         nodeMouseDoubleClickEvent.getY(),
                                         nodeMouseDoubleClickEvent.getMouseEvent().getClientX(),
                                         nodeMouseDoubleClickEvent.getMouseEvent().getClientY());
          event.setShiftKeyDown(nodeMouseDoubleClickEvent.isShiftKeyDown());
          event.setAltKeyDown(nodeMouseDoubleClickEvent.isAltKeyDown());
          event.setMetaKeyDown(nodeMouseDoubleClickEvent.isMetaKeyDown());
          event.setButtonLeft(nodeMouseDoubleClickEvent.isButtonLeft());
          event.setButtonMiddle(nodeMouseDoubleClickEvent.isButtonMiddle());
          event.setButtonRight(nodeMouseDoubleClickEvent.isButtonRight());
          eventHandler.handle(event);
          restoreClickHandler();
        }
      })
  };
}

相关文章