Example usage for com.google.gwt.user.client Event getClientY

List of usage examples for com.google.gwt.user.client Event getClientY

Introduction

In this page you can find the example usage for com.google.gwt.user.client Event getClientY.

Prototype

public final int getClientY() 

Source Link

Document

Gets the mouse y-position within the browser window's client area.

Usage

From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java

License:Apache License

public static boolean isLessThanXpixelsFrom(Element e, int hDistance, int vDistance) {
    Event currentEvent = Event.getCurrentEvent();
    return isLessThanXpixelsFrom0(e, hDistance, vDistance, currentEvent.getClientX(),
            currentEvent.getClientY());
}

From source file:ch.unifr.pai.ice.client.dragNdrop.DND4users4spaces.java

License:Apache License

/*******************************************************************
 * Blobs generator with the draggable capabilities - Pseudo randomly position (array of position)
 *******************************************************************/

private void addBlob(int xPos, int yPos, String image, String widthSize, String heightSize, int row, int col,
        String textColor) {//from w ww. j a v a2s .co  m

    DraggableLabelledBlob blob = new DraggableLabelledBlob(String.valueOf(col), image);
    blob.setSize(widthSize, heightSize);
    blob.setBlobNumber((row * 10) + col);
    blob.setVisible(true);
    blob.setTitle(String.valueOf((row * 10) + col));
    blob.getElement().getStyle().setColor(textColor);

    DragNDrop.makeDraggable(blob, DragConfiguration.withProxy(new DragNDropHandler() {

        @Override
        public void onStartDrag(String deviceId, Widget draggedWidget) {

            if (!((DraggableLabelledBlob) draggedWidget).isDragStarted()) {

                // set the starting time
                ((DraggableLabelledBlob) draggedWidget).setDragStarted(true);
                ((DraggableLabelledBlob) draggedWidget).setDragStartTime(System.currentTimeMillis());
            }
        }

        @Override
        public void onEndOfDrop(String deviceId, Widget draggedWidget, int dragProxyLeft, int dragProxyTop,
                Event event) {
        }

        @Override
        public boolean onDrop(String deviceId, Widget draggedWidget, int dragProxyLeft, int dragProxyTop,
                Event event, DropTargetHandler dropTarget, boolean outOfBox) {

            return true;
        }
    }

    ));

    final FocusPanel panel = new FocusPanel();

    panel.addMouseMoveHandler(new MouseMoveHandler() {

        @Override
        public void onMouseMove(MouseMoveEvent event) {
            String deviceId = UUID.getUUIDForEvent(event.getNativeEvent());
            event.getRelativeX(panel.getElement());
            event.getClientY();
        }
    });

    // dragPanel.add(blob, xPos, yPos);
    dragGrid.setWidget(row, col, blob);

}

From source file:ch.unifr.pai.ice.client.dragNdrop.DND4users4spaces.java

License:Apache License

/************************************************************************
 * Blobs generator with the draggable capabilities - Equally distributed
 ************************************************************************/

private void addBlob(int posInGrid, String image, String widthSize, String heightSize, int userNo, int row,
        int col, String textColor) {

    DraggableLabelledBlob blob = new DraggableLabelledBlob(String.valueOf(col), image);
    blob.setSize(widthSize, heightSize);
    blob.setBlobNumber((userNo * 10) + col);
    blob.setVisible(true);/*  w  w  w . jav a2  s.  c  o m*/
    blob.setTitle(String.valueOf((userNo * 10) + col));
    blob.getElement().getStyle().setColor(textColor);

    DragNDrop.makeDraggable(blob, DragConfiguration.withProxy(new DragNDropHandler() {

        @Override
        public void onStartDrag(String deviceId, Widget draggedWidget) {

            if (!((DraggableLabelledBlob) draggedWidget).isDragStarted()) {

                // set the starting time
                ((DraggableLabelledBlob) draggedWidget).setDragStarted(true);
                ((DraggableLabelledBlob) draggedWidget).setDragStartTime(System.currentTimeMillis());
            }
        }

        @Override
        public void onEndOfDrop(String deviceId, Widget draggedWidget, int dragProxyLeft, int dragProxyTop,
                Event event) {
        }

        @Override
        public boolean onDrop(String deviceId, Widget draggedWidget, int dragProxyLeft, int dragProxyTop,
                Event event, DropTargetHandler dropTarget, boolean outOfBox) {

            return true;
        }
    }

    ));

    final FocusPanel panel = new FocusPanel();

    panel.addMouseMoveHandler(new MouseMoveHandler() {

        @Override
        public void onMouseMove(MouseMoveEvent event) {
            String deviceId = UUID.getUUIDForEvent(event.getNativeEvent());
            event.getRelativeX(panel.getElement());
            event.getClientY();
        }
    });

    dragGrid.setWidget(row, posInGrid, blob);

}

From source file:com.alkacon.geranium.client.dnd.DNDHandler.java

License:Open Source License

/**
 * Executed on mouse move while dragging.<p>
 * /*from   w w w  . j a  v a  2 s .com*/
 * @param event the event
 */
protected void onMove(Event event) {

    m_clientX = event.getClientX();
    m_clientY = event.getClientY();
    checkTargets();
    positionHelper();
    scrollAction();
}

From source file:com.alkacon.geranium.client.dnd.DNDHandler.java

License:Open Source License

/**
 * Executed on mouse up while dragging.<p>
 * /*from  w ww  .j a  v a 2s  . co m*/
 * @param event the event
 */
protected void onUp(Event event) {

    m_clientX = event.getClientX();
    m_clientY = event.getClientY();
    if ((m_currentTarget == null) || (m_currentTarget.getPlaceholderIndex() < 0)) {
        cancel();
    } else {
        drop();
    }
}

From source file:com.areahomeschoolers.baconbits.client.content.calendar.monthview.MonthView.java

License:Open Source License

private void dayClicked(Event event) {
    int y = event.getClientY() + Window.getScrollTop() - DOM.getAbsoluteTop(appointmentCanvas.getElement());
    int x = event.getClientX() + Window.getScrollLeft() - DOM.getAbsoluteLeft(appointmentCanvas.getElement());

    int row = (int) Math.floor(y / (appointmentCanvas.getOffsetHeight() / monthViewRequiredRows));
    int col = (int) Math.floor(x / (appointmentCanvas.getOffsetWidth() / DAYS_IN_A_WEEK));
    calendarWidget.fireTimeBlockClickEvent(cellDate(row * DAYS_IN_A_WEEK + col));
}

From source file:com.cgxlib.xq.client.plugins.MousePlugin.java

License:Apache License

protected int getClientY(Event e) {
    if (touchSupported) {
        return e.getTouches().get(0).getClientY();
    } else {//from  www  .ja v a 2s . c o m
        return e.getClientY();
    }
}

From source file:com.ephesoft.gxt.rv.client.widget.DataTableGrid.java

License:Open Source License

@Override
protected void onMouseDown(Event event) {
    super.onMouseDown(event);
    if (event.getButton() == Event.BUTTON_RIGHT) {
        if (overlay == null) {
            copyFromCell = getCell(event);
            if (copyFromCell != null && copyFromCell.getCol() > 0) {
                overlay = new Overlay();
                disableOverlayContextMenu(overlay);
                overlay.setPosition(event.getClientX(), event.getClientY());
                RootPanel.get().add(overlay);
            }/*from  w  w w. j ava 2s  . c om*/
        } else {
            RootPanel.get().remove(overlay);
            overlay = null;
            GridCell mouseUpCell = getCell(event);
            if (copyFromCell != null && mouseUpCell != null) {
                int fromRow = copyFromCell.getRow();
                int toRow = mouseUpCell.getRow();
                int fromColumn = copyFromCell.getCol();
                int toColumn = mouseUpCell.getCol();
                copyValues(fromRow, toRow, fromColumn, toColumn);
                refresh();
                cellSelectionModel.selectCell(toRow, toColumn);
                Document currentDocument = ReviewValidateNavigator.getCurrentDocument();
                ReviewValidateEventBus.fireEvent(new DocumentModificationEvent(currentDocument));
            }
        }
    }
}

From source file:com.google.livingstories.client.ui.AutoHidePopupPanel.java

License:Apache License

@Override
protected void onPreviewNativeEvent(NativePreviewEvent event) {
    super.onPreviewNativeEvent(event);
    Event nativeEvent = Event.as(event.getNativeEvent());
    if (nativeEvent.getTypeInt() == Event.ONMOUSEDOWN) {
        // This is a hack to make the popup panel not hide when the user drags
        // the window scrollbar thumb.
        // Since we are unable to override relevant methods to achieve this effect,
        // we just tell the hide() method to skip the next call it sees.
        if (nativeEvent.getClientX() > Window.getClientWidth()
                || nativeEvent.getClientY() > Window.getClientHeight()) {
            skipHide = true;/*from   www. java2 s .co m*/
        }
    } else if (nativeEvent.getTypeInt() == Event.ONCLICK) {
        Element source = Element.as(nativeEvent.getEventTarget());
        if (source.getClassName().contains(NON_HIDING_CLASS)) {
            return;
        }
        if (wholePopupIsLink || source.getTagName().equalsIgnoreCase("A")
                || source.getClassName().contains("primaryLink")
                || source.getClassName().contains("secondaryLink")
                || source.getClassName().contains(Resources.INSTANCE.css().clickable())) {
            // Need to use a deferred command here because if we hide the panel immediately,
            // it somehow prevents the link from seeing the event.
            DeferredCommand.addCommand(new Command() {
                @Override
                public void execute() {
                    hide();
                }
            });
        }
    } else if (nativeEvent.getTypeInt() == Event.ONKEYUP && nativeEvent.getKeyCode() == KeyCodes.KEY_ESCAPE) {
        // also hide the dialog if that happens. Handy to provide this, in case the close
        // button somehow gets hidden offscreen.
        hide();
    }
}

From source file:com.googlecode.kanbanik.client.components.WindowBox.java

License:Apache License

@Override
public void onBrowserEvent(Event event) {

    // If we're not yet dragging, only trigger mouse events if the event occurs
    // in the caption wrapper
    if (this.resizable) {
        switch (event.getTypeInt()) {
        case Event.ONMOUSEDOWN:
        case Event.ONMOUSEUP:
        case Event.ONMOUSEMOVE:
        case Event.ONMOUSEOVER:
        case Event.ONMOUSEOUT:

            if (this.dragMode >= 0 || calcDragMode(event.getClientX(), event.getClientY()) >= 0) {
                // paste'n'copy from Widget.onBrowserEvent
                switch (DOM.eventGetType(event)) {
                case Event.ONMOUSEOVER:
                    // Only fire the mouse over event if it's coming from outside this
                    // widget.
                case Event.ONMOUSEOUT:
                    // Only fire the mouse out event if it's leaving this
                    // widget.
                    Element related = event.getRelatedEventTarget().cast();
                    if (related != null && getElement().isOrHasChild(related)) {
                        return;
                    }/*from   w w w  . j  a  v a 2 s  .  c o m*/
                    break;
                }
                DomEvent.fireNativeEvent(event, this, this.getElement());
                return;
            }
            if (this.dragMode < 0)
                this.updateCursor(this.dragMode);
        }
    }

    super.onBrowserEvent(event);
}