Java Code Examples for com.google.gwt.user.client.Event#getClientX()
The following examples show how to use
com.google.gwt.user.client.Event#getClientX() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HorizontalPanelWithHint.java From unitime with Apache License 2.0 | 6 votes |
public void onBrowserEvent(Event event) { int x = 10 + event.getClientX() + getElement().getOwnerDocument().getScrollLeft(); int y = 10 + event.getClientY() + getElement().getOwnerDocument().getScrollTop(); switch (DOM.eventGetType(event)) { case Event.ONMOUSEMOVE: if (iHint.isShowing()) { iHint.setPopupPosition(x, y); } else { iShowHint.cancel(); iHint.setPopupPosition(x, y); iShowHint.schedule(1000); } break; case Event.ONMOUSEOUT: iShowHint.cancel(); if (iHint.isShowing()) iHideHint.schedule(1000); break; } }
Example 2
Source File: InfoPanelImpl.java From unitime with Apache License 2.0 | 6 votes |
public void onBrowserEvent(Event event) { if (iHint.getText().isEmpty()) return; iX = 10 + event.getClientX() + getElement().getOwnerDocument().getScrollLeft(); iY = 10 + event.getClientY() + getElement().getOwnerDocument().getScrollTop(); switch (DOM.eventGetType(event)) { case Event.ONMOUSEMOVE: if (iInfoPanel.isShowing()) { int maxX = Window.getScrollLeft() + Window.getClientWidth() - iInfoPanel.getOffsetWidth() - 10; iInfoPanel.setPopupPosition(Math.min(iX, maxX), iY); } else if (iInfo.getRowCount() > 0) { iShowInfo.cancel(); iShowInfo.schedule(1000); } break; case Event.ONMOUSEOUT: iShowInfo.cancel(); if (iInfoPanel.isShowing()) iHideInfo.schedule(1000); break; } }
Example 3
Source File: ViewContainerToElementMapper.java From jetpad-projectional-open-source with Apache License 2.0 | 6 votes |
private MouseEvent toMouseEvent(Event e) { int cx = e.getClientX(); int cy = e.getClientY(); int scrollLeft = Window.getScrollLeft(); int scrollTop = Window.getScrollTop(); int absoluteLeft = myRootDiv.getAbsoluteLeft(); int absoluteTop = myRootDiv.getAbsoluteTop(); int elScrollTop = myRootDiv.getScrollTop(); int elScrollLeft = myRootDiv.getScrollLeft(); int x = cx + scrollLeft - absoluteLeft + elScrollLeft; int y = cy + scrollTop - absoluteTop + elScrollTop; return new MouseEvent(x, y); }
Example 4
Source File: CubaFileUploadProgressWindow.java From cuba with Apache License 2.0 | 5 votes |
private boolean cursorInsideBrowserContentArea(Event event) { if (event.getClientX() < 0 || event.getClientY() < 0) { // Outside to the left or above return false; } if (event.getClientX() > Window.getClientWidth() || event.getClientY() > Window.getClientHeight()) { // Outside to the right or below return false; } return true; }
Example 5
Source File: CubaResizableTextAreaWrapperWidget.java From cuba with Apache License 2.0 | 5 votes |
protected void handleResize(Event event) { //calculate and set the new size if (dragDrop) { int mouseX = event.getClientX(); int mouseY = event.getClientY(); int absoluteLeft = getAbsoluteLeft(); int absoluteTop = getAbsoluteTop(); ComputedStyle cs = new ComputedStyle(getElement().getFirstChildElement()); //do not allow mirror-functionality if (mouseY > absoluteTop + cs.getDoubleProperty("min-height") && mouseX > absoluteLeft + MINIMAL_WIDTH) { int width = mouseX - absoluteLeft + 2; int height = mouseY - absoluteTop + 2; switch (resizableDirection) { case BOTH: setHeight(height + "px"); setWidth(width + "px"); break; case VERTICAL: setHeight(height + "px"); break; case HORIZONTAL: setWidth(width + "px"); break; } if (resizeHandler != null) { resizeHandler.handleResize(); } } } }
Example 6
Source File: OffsetPosition.java From swellrt with Apache License 2.0 | 5 votes |
/** * Create a offset position base on the event's client X, Y. The return offset * position is relative to the Document body coordinate. * * @param event */ public OffsetPosition(Event event) { // convert the event's client coordinate system, which is client area base, to the // body position coordinate system. this.left = event.getClientX() + Window.getScrollLeft() - Document.get().getBodyOffsetLeft(); this.top = event.getClientY() + Window.getScrollTop() - Document.get().getBodyOffsetTop(); this.offsetParent = null; }
Example 7
Source File: InputSlider.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
private int getRelativeX(Event event) { int clientX = event.getClientX(); if ((DOM.eventGetType(event) & Event.TOUCHEVENTS) != 0) { clientX = event.getTouches().get(0).getClientX(); } return clientX - InputSlider.this.backgroundBar.getAbsoluteLeft() + InputSlider.this.backgroundBar.getScrollLeft() + InputSlider.this.backgroundBar.getOwnerDocument().getScrollLeft(); }
Example 8
Source File: OffsetPosition.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
/** * Create a offset position base on the event's client X, Y. The return offset * position is relative to the Document body coordinate. * * @param event */ public OffsetPosition(Event event) { // convert the event's client coordinate system, which is client area base, to the // body position coordinate system. this.left = event.getClientX() + Window.getScrollLeft() - Document.get().getBodyOffsetLeft(); this.top = event.getClientY() + Window.getScrollTop() - Document.get().getBodyOffsetTop(); this.offsetParent = null; }
Example 9
Source File: TimeGrid.java From unitime with Apache License 2.0 | 4 votes |
public void onBrowserEvent(Event event) { if (iDummy) return; Element target = DOM.eventGetTarget(event); boolean anchor = false; for (; target != null; target = DOM.getParent(target)) { String tag = target.getPropertyString("tagName"); if ("a".equalsIgnoreCase(tag)) { anchor = true; break; } else if ("div".equalsIgnoreCase(tag)) { break; } } EventTarget related = event.getRelatedEventTarget(); switch (DOM.eventGetType(event)) { case Event.ONCLICK: select(false); if (!anchor) { MeetingClickEvent e = new MeetingClickEvent(Meeting.this); for (MeetingClickHandler h: iMeetingClickHandlers) h.onMeetingClick(e); } break; case Event.ONMOUSEOVER: if (related == null || !getElement().isOrHasChild((Element)related.cast())) { select(true); } break; case Event.ONMOUSEOUT: if (related == null || !getElement().isOrHasChild((Element)related.cast())) { select(false); } break; case Event.ONMOUSEMOVE: int relativeX = event.getClientX() - getElement().getAbsoluteLeft() + getElement().getScrollLeft() + getElement().getOwnerDocument().getScrollLeft(); if (iRTL) relativeX = iCellWidth - relativeX; if (relativeX < iLeft - 6 - getDay() * iCellWidth || relativeX > iLeft - 2 - getDay() * iCellWidth + iWidth) { select(false); } break; } super.onBrowserEvent(event); }
Example 10
Source File: TimeGrid.java From unitime with Apache License 2.0 | 4 votes |
@Override public void onBrowserEvent(Event event) { if (Event.ONMOUSEMOVE == DOM.eventGetType(event) && !iSelection.isActive() && iMoving != null) { iMoving.onBrowserEvent(event); if (iMoving.iCursor != null) getElement().getStyle().setCursor(iMoving.iCursor); return; } double x = event.getClientX() - getAbsoluteLeft() + Window.getScrollLeft(); double y = event.getClientY() - getAbsoluteTop() + Window.getScrollTop(); int slot = 3 * Math.min(Math.max(0, (int)Math.round(4 * (y - 1 + iStart * iCellHeight) / iCellHeight)), 96); int day = Math.min(Math.max(0, (int)Math.floor((x - 2) / iCellWidth)), iDays.length - 1); int weeks = (isSingleRoom() ? iSelectedWeeks.size() : iRoomResources.size()); int week = Math.min(Math.max(0, (int)Math.floor(weeks * (x - 2 - iCellWidth * day) / (iCellWidth - 6))), weeks - 1); if (iRTL) { day = iDays.length - day - 1; week = weeks - week - 1; } int dayOfWeek = iDays[day]; int h = slot / 12; int m = 5 * (slot % 12); String time = (CONSTANTS.useAmPm() ? (h == 0 ? "12": h <= 12 ? h : h-12) : h) + ":" + (m < 10 ? "0" : "") + m + (CONSTANTS.useAmPm() ? (h <= 11 ? "a" : "p") : ""); int dayInv = (iDayOfWeeks == null ? (7 + dayOfWeek - iPropertiesProvider.getFirstDayOfWeek()) % 7 : dayOfWeek); String text = (iDayOfWeeks == null ? CONSTANTS.longDays()[dayOfWeek] : iDayOfWeeks.get(dayOfWeek)) + " " + (isSingleRoom() ? iSelectedWeeks.get(week) : iSelectedWeeks.get(0)).getDayNames().get(dayInv) + " " + time + (isSingleRoom() ? "" : " " + iRoomResources.get(week).getName()); ResourceInterface room = (isSingleRoom() ? iRoomResources.get(0) : iRoomResources.get(week)); iPopup.setPopupPosition(event.getClientX() + Window.getScrollLeft(), event.getClientY() + Window.getScrollTop()); getElement().getStyle().setCursor(Cursor.CROSSHAIR); switch (DOM.eventGetType(event)) { case Event.ONMOUSEDOWN: iSelection.setStart(dayOfWeek, slot, week); iSelection.setEnd(dayOfWeek, slot, week); iSelection.setVisible(true); iSelection.setActive(true); break; case Event.ONMOUSEMOVE: iSelection.setEnd(dayOfWeek, slot, week); if (!iPopup.isShowing()) iPopup.show(); if (!room.getId().equals(iLastRoomId)) { RoomHint.showHint(iPopup.getElement(), room.getId(), "", (room.hasDistance() ? String.valueOf(Math.round(room.getDistance())) : ""), false); iLastRoomId = room.getId(); } break; case Event.ONMOUSEUP: onMouseUp(); break; case Event.ONMOUSEOVER: if (!iPopup.isShowing() && (iSelection.isActive() || iMoving == null)) iPopup.show(); if (iSelection.isActive() && !iSelection.isVisible()) { iSelection.setVisible(true); } if (!room.getId().equals(iLastRoomId)) { RoomHint.showHint(iPopup.getElement(), room.getId(), "", (room.hasDistance() ? String.valueOf(Math.round(room.getDistance())) : ""), false); iLastRoomId = room.getId(); } break; case Event.ONMOUSEOUT: Element child = DOM.eventGetToElement(event); if (child != null && !getElement().isOrHasChild(child)) { if (iPopup.isShowing()) { iPopup.hide(); RoomHint.hideHint(); iLastRoomId = null; } iSelection.setVisible(false); } /* if (iSelection.isActive() && !DOM.isOrHasChild(TimeGrid.this.getElement(), DOM.eventGetToElement(event))) { iSelection.setActive(false); } */ break; } iHint.setText((iSelection.isVisible() && iSelection.isActive() ? iSelection.toString() : text)); event.preventDefault(); event.stopPropagation(); }
Example 11
Source File: CellContainerToDomMapper.java From jetpad-projectional-open-source with Apache License 2.0 | 4 votes |
private MouseEvent toMouseEvent(Event e) { Vector base = new Vector(e.getClientX() + myScrollLeft, e.getClientY() + myScrollTop); return new MouseEvent(base); }
Example 12
Source File: FinderPanel.java From core with GNU Lesser General Public License v2.1 | 4 votes |
@Override protected int getEventPosition(Event event) { return event.getClientX(); }
Example 13
Source File: CollapsibleSplitLayoutPanel.java From core with GNU Lesser General Public License v2.1 | 4 votes |
@Override protected int getEventPosition(Event event) { return event.getClientX(); }
Example 14
Source File: EventWrapper.java From swellrt with Apache License 2.0 | 2 votes |
/** * @return A string describing the client x,y position, * e.g., " (100, 100)" */ private static String mousePoint(Event event) { return " (" + event.getClientX() + ", " + event.getClientY() + ")"; }
Example 15
Source File: EventWrapper.java From incubator-retired-wave with Apache License 2.0 | 2 votes |
/** * @return A string describing the client x,y position, * e.g., " (100, 100)" */ private static String mousePoint(Event event) { return " (" + event.getClientX() + ", " + event.getClientY() + ")"; }