Java Code Examples for com.vaadin.client.WidgetUtil#getTouchOrMouseClientY()

The following examples show how to use com.vaadin.client.WidgetUtil#getTouchOrMouseClientY() . 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: CubaMainTabSheetConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@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();
            event.preventDefault();
        }
    };
}
 
Example 2
Source File: CubaWindowConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
protected void init() {
    super.init();

    getWidget().contextMenuHandler = event -> {
        lastContextMenuX = WidgetUtil.getTouchOrMouseClientX(event);
        lastContextMenuY = WidgetUtil.getTouchOrMouseClientY(event);

        if (getState().hasContextActionHandlers) {
            rpc.onWindowContextMenu();

            event.stopPropagation();
            event.preventDefault();
        }
    };
    getWidget().clickOnModalityCurtain = () -> rpc.performCloseAction();
}
 
Example 3
Source File: CubaFileUploadProgressWindow.java    From cuba with Apache License 2.0 5 votes vote down vote up
private void setSize(Event event) {
    if (!cursorInsideBrowserContentArea(event)) {
        // Only drag while cursor is inside the browser client area
        return;
    }

    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");
}
 
Example 4
Source File: CubaFileUploadProgressWindow.java    From cuba with Apache License 2.0 5 votes vote down vote up
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);
        }

        event.preventDefault();
    }
}
 
Example 5
Source File: CubaFileUploadProgressWindow.java    From cuba with Apache License 2.0 5 votes vote down vote up
private void beginMovingWindow(Event event) {
    if (draggable) {
        showDraggingCurtain();
        dragging = true;
        startX = WidgetUtil.getTouchOrMouseClientX(event);
        startY = WidgetUtil.getTouchOrMouseClientY(event);
        origX = getElement().getAbsoluteLeft();
        origY = getElement().getAbsoluteTop();
        DOM.setCapture(getElement());

        event.preventDefault();
    }
}
 
Example 6
Source File: CubaTreeTableWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void showContextMenu(Event event) {
    if (_delegate.contextMenuEnabled && enabled && (_delegate.customContextMenu != null || actionKeys != null)) {
        // Show context menu if there are registered action handlers
        int left = WidgetUtil.getTouchOrMouseClientX(event)
                + Window.getScrollLeft();
        int top = WidgetUtil.getTouchOrMouseClientY(event)
                + Window.getScrollTop();

        selectRowForContextMenuActions(event);

        showContextMenu(left, top);
    }
}
 
Example 7
Source File: CubaFileUploadProgressWindow.java    From cuba with Apache License 2.0 4 votes vote down vote up
private void onResizeEvent(Event event) {
    if (resizable && WidgetUtil.isTouchEventOrLeftMouseButton(event)) {
        switch (event.getTypeInt()) {
            case Event.ONMOUSEDOWN:
            case Event.ONTOUCHSTART:
                showResizingCurtain();
                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;
        }
    }
}