List of usage examples for com.vaadin.client WidgetUtil getTouchOrMouseClientY
public static int getTouchOrMouseClientY(NativeEvent currentGwtEvent)
From source file:com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadProgressWindow.java
License:Apache License
private void onResizeEvent(Event event) { if (resizable && WidgetUtil.isTouchEventOrLeftMouseButton(event)) { switch (event.getTypeInt()) { case Event.ONMOUSEDOWN: case Event.ONTOUCHSTART: showResizingCurtain();/* w w w . j av a 2 s .c o m*/ if (BrowserInfo.get().isIE()) { resizeBox.getStyle().setVisibility(Style.Visibility.HIDDEN); } resizing = true; startX = WidgetUtil.getTouchOrMouseClientX(event); startY = WidgetUtil.getTouchOrMouseClientY(event); origW = getElement().getOffsetWidth(); origH = getElement().getOffsetHeight(); DOM.setCapture(getElement()); event.preventDefault(); break; case Event.ONMOUSEUP: case Event.ONTOUCHEND: setSize(event); case Event.ONTOUCHCANCEL: DOM.releaseCapture(getElement()); case Event.ONLOSECAPTURE: hideResizingCurtain(); if (BrowserInfo.get().isIE()) { resizeBox.getStyle().clearVisibility(); } resizing = false; break; case Event.ONMOUSEMOVE: case Event.ONTOUCHMOVE: if (resizing) { setSize(event); event.preventDefault(); } break; default: event.preventDefault(); break; } } }
From source file:com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadProgressWindow.java
License:Apache License
private void setSize(Event event) { if (!cursorInsideBrowserContentArea(event)) { // Only drag while cursor is inside the browser client area return;/*w ww . ja v a 2s. co m*/ } int w = WidgetUtil.getTouchOrMouseClientX(event) - startX + origW; int h = WidgetUtil.getTouchOrMouseClientY(event) - startY + origH; w = Math.max(w, getMinWidth()); h = Math.max(h, getMinHeight()); setWidth(w + "px"); setHeight(h + "px"); }
From source file:com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadProgressWindow.java
License:Apache License
private void moveWindow(Event event) { if (dragging) { if (cursorInsideBrowserContentArea(event)) { // Only drag while cursor is inside the browser client area final int x = WidgetUtil.getTouchOrMouseClientX(event) - startX + origX; final int y = WidgetUtil.getTouchOrMouseClientY(event) - startY + origY; setPopupPosition(x, y);/*from w w w .j a v a 2 s. co m*/ } event.preventDefault(); } }
From source file:com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadProgressWindow.java
License:Apache License
private void beginMovingWindow(Event event) { if (draggable) { showDraggingCurtain();/*from w w w . j a v a 2s .c om*/ dragging = true; startX = WidgetUtil.getTouchOrMouseClientX(event); startY = WidgetUtil.getTouchOrMouseClientY(event); origX = getElement().getAbsoluteLeft(); origY = getElement().getAbsoluteTop(); DOM.setCapture(getElement()); event.preventDefault(); } }
From source file:com.haulmont.cuba.web.toolkit.ui.client.tabsheet.CubaTabSheetConnector.java
License:Apache License
@Override protected void init() { super.init(); getWidget().tabContextMenuHandler = new CubaTabSheetWidget.TabContextMenuHandler() { @Override/*from w w w .j a v a 2s. c om*/ public void onContextMenu(int tabIndex, ContextMenuEvent event) { lastContextMenuX = WidgetUtil.getTouchOrMouseClientX(event.getNativeEvent()); lastContextMenuY = WidgetUtil.getTouchOrMouseClientY(event.getNativeEvent()); if (getState().hasActionsHandlers) { rpc.onTabContextMenu(tabIndex); event.stopPropagation(); event.preventDefault(); } } }; }
From source file:com.haulmont.cuba.web.toolkit.ui.client.window.CubaWindowConnector.java
License:Apache License
@Override protected void init() { super.init(); getWidget().contextMenuHandler = new CubaWindowWidget.ContextMenuHandler() { @Override/*from w ww . ja va 2 s. co m*/ public void onContextMenu(Event event) { lastContextMenuX = WidgetUtil.getTouchOrMouseClientX(event); lastContextMenuY = WidgetUtil.getTouchOrMouseClientY(event); if (getState().hasContextActionHandlers) { rpc.onWindowContextMenu(); event.stopPropagation(); event.preventDefault(); } } }; getWidget().clickOnModalityCurtain = () -> rpc.performCloseAction(); }
From source file:com.haulmont.cuba.web.widgets.client.addons.dragdroplayouts.ui.VLayoutDragDropMouseHandler.java
License:Apache License
private boolean isEventOnScrollBar(NativeEvent event) { Element element = Element.as(event.getEventTarget()); ;/*from w ww .j a va2s . co m*/ if (WidgetUtil.mayHaveScrollBars(element)) { final int nativeScrollbarSize = WidgetUtil.getNativeScrollbarSize(); int x = WidgetUtil.getTouchOrMouseClientX(event) - element.getAbsoluteLeft(); int y = WidgetUtil.getTouchOrMouseClientY(event) - element.getAbsoluteTop(); // Hopefully we have horizontal scroll. final int scrollWidth = element.getScrollWidth(); final int clientWidth = element.getClientWidth(); if (scrollWidth > clientWidth && clientWidth - nativeScrollbarSize < x) { return true; } // Hopefully we have vertical scroll. final int scrollHeight = element.getScrollHeight(); final int clientHeight = element.getClientHeight(); if (scrollHeight > clientHeight && clientHeight - nativeScrollbarSize < y) { return true; } } return false; }
From source file:com.haulmont.cuba.web.widgets.client.tabsheet.CubaTabSheetConnector.java
License:Apache License
@Override protected void init() { super.init(); getWidget().tabContextMenuHandler = (tabIndex, event) -> { lastContextMenuX = WidgetUtil.getTouchOrMouseClientX(event.getNativeEvent()); lastContextMenuY = WidgetUtil.getTouchOrMouseClientY(event.getNativeEvent()); if (getState().hasActionsHandlers) { rpc.onTabContextMenu(tabIndex); event.stopPropagation();/* www.j a va 2 s . c o m*/ event.preventDefault(); } }; }
From source file:com.haulmont.cuba.web.widgets.client.window.CubaWindowConnector.java
License:Apache License
@Override protected void init() { super.init(); getWidget().contextMenuHandler = event -> { lastContextMenuX = WidgetUtil.getTouchOrMouseClientX(event); lastContextMenuY = WidgetUtil.getTouchOrMouseClientY(event); if (getState().hasContextActionHandlers) { rpc.onWindowContextMenu();//from w ww. ja va 2 s. com event.stopPropagation(); event.preventDefault(); } }; getWidget().clickOnModalityCurtain = () -> rpc.performCloseAction(); }