当前位置: 首页>>代码示例>>Java>>正文


Java NativeEvent.BUTTON_LEFT属性代码示例

本文整理汇总了Java中com.google.gwt.dom.client.NativeEvent.BUTTON_LEFT属性的典型用法代码示例。如果您正苦于以下问题:Java NativeEvent.BUTTON_LEFT属性的具体用法?Java NativeEvent.BUTTON_LEFT怎么用?Java NativeEvent.BUTTON_LEFT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.google.gwt.dom.client.NativeEvent的用法示例。


在下文中一共展示了NativeEvent.BUTTON_LEFT属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onMouseDown

@Override
public void onMouseDown(MouseDownEvent event) {

    startX = event.getClientX();
    startY = event.getClientY();

    if (isDisabled() || event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
        return;
    }

    clickTarget = Element.as(event.getNativeEvent().getEventTarget());
    mouseMoveCanceled = false;

    if ((weekGrid.getCalendar().isItemMoveAllowed() && getCalendarItem().isMoveable())
            || (clickTargetsResize() && getCalendarItem().isResizeable())) {

        moveRegistration = addMouseMoveHandler(this);
        setFocus(true);
        try {
            startYrelative = (int) ((double) event.getRelativeY(caption) % slotHeight);
            startXrelative = (event.getRelativeX(weekGrid.getElement())
                    - weekGrid.timebar.getOffsetWidth())
                    % getDateCellWidth();
        } catch (Exception e) {
            GWT.log("Exception calculating relative start position", e);
        }
        mouseMoveStarted = false;
        Style s = getElement().getStyle();
        s.setZIndex(1000);
        startDatetimeFrom = (Date) calendarItem.getStartTime().clone();
        startDatetimeTo = (Date) calendarItem.getEndTime().clone();
        Event.setCapture(getElement());
    }

    // make sure the right cursor is always displayed
    if (clickTargetsResize() && getCalendarItem().isResizeable()) {
        addGlobalResizeStyle();
    }

    /*
     * We need to stop the event propagation or else the WeekGrid range
     * select will kick in
     */
    event.stopPropagation();
    event.preventDefault();
}
 
开发者ID:blackbluegl,项目名称:calendar-component,代码行数:46,代码来源:DateCellDayItem.java

示例2: onMouseUp

@Override
public void onMouseUp(MouseUpEvent event) {
    if (mouseMoveCanceled
            || event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
        return;
    }

    Event.releaseCapture(getElement());
    setFocus(false);
    if (moveRegistration != null) {
        moveRegistration.removeHandler();
        moveRegistration = null;
    }

    int endX = event.getClientX();
    int endY = event.getClientY();
    int xDiff = 0, yDiff = 0;
    if (startX != -1 && startY != -1) {
        // Drag started
        xDiff = startX - endX;
        yDiff = startY - endY;
    }

    startX = -1;
    startY = -1;
    mouseMoveStarted = false;
    Style s = getElement().getStyle();
    s.setZIndex(1);

    if (!clickTargetsResize()) {

        // check if mouse has moved over threshold of 3 pixels
        boolean mouseMoved = (xDiff < -3 || xDiff > 3 || yDiff < -3 || yDiff > 3);

        if (!weekGrid.getCalendar().isDisabled() && mouseMoved) {
            // Item Move:
            // - calendar must be enabled
            // - calendar must not be in read-only mode
            weekGrid.itemMoved(this);

        } else if (!weekGrid.getCalendar().isDisabled() && getCalendarItem().isClickable()) {
            // Item Click:
            // - calendar must be enabled (read-only is allowed)
            EventTarget et = event.getNativeEvent().getEventTarget();
            Element e = Element.as(et);
            if (e == caption || e == eventContent
                    || e.getParentElement() == caption) {
                if (weekGrid.getCalendar().getItemClickListener() != null) {
                    weekGrid.getCalendar().getItemClickListener().itemClick(calendarItem);
                }
            }
        }

    } else {
        // click targeted resize bar
        removeGlobalResizeStyle();
        if (weekGrid.getCalendar().getItemResizeListener() != null) {
            weekGrid.getCalendar().getItemResizeListener().itemResized(calendarItem);
        }
        dateCell.recalculateItemWidths();
    }
}
 
开发者ID:blackbluegl,项目名称:calendar-component,代码行数:62,代码来源:DateCellDayItem.java

示例3: onMouseUp

@Override
public void onMouseUp(MouseUpEvent event) {
    if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
        return;
    }

    if (moveRegistration != null) {
        Event.releaseCapture(getElement());
        moveRegistration.removeHandler();
        moveRegistration = null;
        keyDownHandler.removeHandler();
        keyDownHandler = null;
    }

    Widget w = (Widget) event.getSource();
    if (w == bottomspacer && monthEventMouseDown) {
        GWT.log("Mouse up over bottomspacer");

    } else if (clickedWidget instanceof MonthItemLabel  && monthEventMouseDown) {

        MonthItemLabel mel = (MonthItemLabel) clickedWidget;

        int endX = event.getClientX();
        int endY = event.getClientY();
        int xDiff = 0, yDiff = 0;
        if (startX != -1 && startY != -1) {
            xDiff = startX - endX;
            yDiff = startY - endY;
        }
        startX = -1;
        startY = -1;
        prevDayDiff = 0;
        prevWeekDiff = 0;

        if (xDiff < -3 || xDiff > 3 || yDiff < -3 || yDiff > 3) {
            itemMoved(movingItem);

        } else if (calendar.getItemClickListener() != null) {
            CalendarItem e = getItemByWidget(mel);

            if(e.isClickable())
            calendar.getItemClickListener().itemClick(e);
        }

        movingItem = null;

    } else if (w == this) {
        getMonthGrid().setSelectionReady();

    } else if (w instanceof Label && labelMouseDown) {
        if (calendar.getDateClickListener() != null) {
            calendar.getDateClickListener().dateClick(DateConstants.toRPCDate(date));
        }
    }

    monthEventMouseDown = false;
    labelMouseDown = false;
    clickedWidget = null;
}
 
开发者ID:blackbluegl,项目名称:calendar-component,代码行数:59,代码来源:SimpleDayCell.java

示例4: onMouseDown

@Override
public void onMouseDown(MouseDownEvent event) {

    if (calendar.isDisabled() || event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
        return;
    }

    Widget w = (Widget) event.getSource();
    clickedWidget = w;

    if (w instanceof MonthItemLabel) {

        // event clicks should be allowed even when read-only
        monthEventMouseDown = true;

        if (calendar.isItemMoveAllowed()
                && ((MonthItemLabel)w).getCalendarItem().isMoveable()) {
            startCalendarItemDrag(event, (MonthItemLabel) w);
        }

    } else if (w == bottomspacer) {

        if (extended) {
            setLimitedCellHeight();
        } else {
            setUnlimitedCellHeight();
        }

        reDraw(true);

    } else if (w instanceof Label) {
        labelMouseDown = true;

    } else if (w == this && !extended) {

        MonthGrid grid = getMonthGrid();
        if (grid.isEnabled() && calendar.isRangeSelectAllowed()) {
            grid.setSelectionStart(this);
            grid.setSelectionEnd(this);
        }
    }

    event.stopPropagation();
    event.preventDefault();
}
 
开发者ID:blackbluegl,项目名称:calendar-component,代码行数:45,代码来源:SimpleDayCell.java


注:本文中的com.google.gwt.dom.client.NativeEvent.BUTTON_LEFT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。