Java Code Examples for com.google.gwt.dom.client.NativeEvent#BUTTON_LEFT
The following examples show how to use
com.google.gwt.dom.client.NativeEvent#BUTTON_LEFT .
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: GanttWidget.java From gantt with Apache License 2.0 | 6 votes |
@Override public void onMouseUp(MouseUpEvent event) { GWT.log("onMouseUp(MouseUpEvent)"); if (event.getNativeButton() == NativeEvent.BUTTON_LEFT) { GanttWidget.this.onTouchOrMouseUp(event.getNativeEvent()); } else { if (secondaryClickOnNextMouseUp) { Element bar = getBar(event.getNativeEvent()); if (bar != null && isEnabled()) { getRpc().stepClicked(getStepUid(bar), event.getNativeEvent(), bar); } } secondaryClickOnNextMouseUp = true; } }
Example 2
Source File: GanttWidget.java From gantt with Apache License 2.0 | 6 votes |
@Override public void onMouseDown(MouseDownEvent event) { GWT.log("onMouseDown(MouseDownEvent)"); if (event.getNativeButton() == NativeEvent.BUTTON_LEFT) { GanttWidget.this.onTouchOrMouseDown(event.getNativeEvent()); } else { secondaryClickOnNextMouseUp = true; new Timer() { @Override public void run() { secondaryClickOnNextMouseUp = false; } }.schedule(CLICK_INTERVAL); event.stopPropagation(); } }
Example 3
Source File: GanttWidget.java From gantt with Apache License 2.0 | 6 votes |
@Override public void onDoubleClick(DoubleClickEvent event) { GWT.log("onDoubleClick(DoubleClickEvent)"); if (event.getNativeButton() == NativeEvent.BUTTON_LEFT) { doubleClickDetectionMaxTimer.cancel(); if (!insideDoubleClickDetectionInterval && numberOfMouseClicksDetected < 2) { return; // ignore double-click } if (targetBarElement != null) { disableClickOnNextMouseUp(); targetBarElement = null; } Element bar = getBar(event.getNativeEvent()); if (bar != null && numberOfMouseClicksDetected > 1) { fireClickRpc(bar, event.getNativeEvent()); } cancelDoubleClickDetection(); } }
Example 4
Source File: CubaWindowWidget.java From cuba with Apache License 2.0 | 6 votes |
@Override public void onBrowserEvent(Event event) { if (contextMenuHandler != null && event.getTypeInt() == Event.ONCONTEXTMENU) { contextMenuHandler.onContextMenu(event); return; } if ((event.getTypeInt() == Event.ONCLICK || event.getTypeInt() == Event.ONMOUSEDOWN) && event.getButton() != NativeEvent.BUTTON_LEFT) { event.preventDefault(); event.stopPropagation(); return; } super.onBrowserEvent(event); }
Example 5
Source File: SvgArrowWidget.java From gantt with Apache License 2.0 | 5 votes |
@Override public void onMouseDown(MouseDownEvent event) { if (event.getNativeButton() == NativeEvent.BUTTON_LEFT) { GWT.log("Starting point Clicked!"); handleDownEvent(event.getNativeEvent()); } }
Example 6
Source File: DateCell.java From calendar-component with Apache License 2.0 | 5 votes |
@Override public void onMouseDown(MouseDownEvent event) { if (event.getNativeButton() == NativeEvent.BUTTON_LEFT) { Element e = Element.as(event.getNativeEvent().getEventTarget()); if (e.getClassName().contains("reserved") || isDisabled() || !weekgrid.getParentCalendar().isRangeSelectAllowed()) { eventRangeStart = -1; } else { eventRangeStart = event.getY(); eventRangeStop = eventRangeStart; Event.setCapture(getElement()); setFocus(true); } } }
Example 7
Source File: MenuController.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
@Override public boolean onMouseDown(MouseDownEvent event, Element context) { if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) { return false; } BlipMenuItemView item = panel.asBlipMenuItem(context); switch (item.getOption()) { case EDIT: actions.startEditing(item.getParent().getParent()); break; case EDIT_DONE: actions.stopEditing(); break; case REPLY: actions.reply(item.getParent().getParent()); break; case DELETE: // We delete the blip without confirmation if shift key is pressed if (event.getNativeEvent().getShiftKey() || Window.confirm(messages.confirmDeletion())) { actions.delete(item.getParent().getParent()); } break; case LINK: actions.popupLink(item.getParent().getParent()); break; default: throw new AssertionError(); } event.preventDefault(); return true; }
Example 8
Source File: CollapseController.java From swellrt with Apache License 2.0 | 5 votes |
@Override public boolean onMouseDown(MouseDownEvent event, Element source) { if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) { return false; } handleClick(panel.fromToggle(source)); return false; }
Example 9
Source File: FocusFrameController.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
@Override public boolean onMouseDown(MouseDownEvent event, Element source) { if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) { return false; } focus.focusWithoutScroll(panel.asBlip(source)); // Cancel bubbling, so that other blips do not grab focus. return true; }
Example 10
Source File: FocusFrameController.java From swellrt with Apache License 2.0 | 5 votes |
@Override public boolean onMouseDown(MouseDownEvent event, Element source) { if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) { return false; } focus.focusWithoutScroll(panel.asBlip(source)); // Cancel bubbling, so that other blips do not grab focus. return true; }
Example 11
Source File: PanListener.java From djvu-html5 with GNU General Public License v2.0 | 5 votes |
@Override public void onMouseDown(MouseDownEvent event) { int button = event.getNativeButton(); if ((button == NativeEvent.BUTTON_LEFT || button == NativeEvent.BUTTON_MIDDLE) && touchId == null) { isMouseDown = true; x = event.getX(); y = event.getY(); event.preventDefault(); Event.setCapture(widget.getElement()); } }
Example 12
Source File: DateCellDayItem.java From calendar-component with Apache License 2.0 | 4 votes |
@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(); }
Example 13
Source File: SuggestionsContainer.java From cuba with Apache License 2.0 | 4 votes |
@Override public void onBrowserEvent(Event event) { if (getElement() == DOM.eventGetTarget(event)) { return; } SuggestionItem item = findItem(DOM.eventGetTarget(event)); switch (DOM.eventGetType(event)) { case Event.ONMOUSEDOWN: { if (BrowserInfo.get().isIE()) { suggestionFieldWidget.iePreventBlur = true; } break; } case Event.ONCLICK: { if (event.getButton() == NativeEvent.BUTTON_LEFT) { performItemCommand(item); } break; } case Event.ONMOUSEOVER: { if (item != null) { selectItem(item); } break; } case Event.ONKEYDOWN: { int keyCode = KeyCodes.maybeSwapArrowKeysForRtl( event.getKeyCode(), LocaleInfo.getCurrentLocale().isRTL() ); switch (keyCode) { case KeyCodes.KEY_UP: selectPrevItem(); preventEvent(event); break; case KeyCodes.KEY_DOWN: selectNextItem(); preventEvent(event); break; case KeyCodes.KEY_ESCAPE: selectItem(null); preventEvent(event); break; case KeyCodes.KEY_TAB: selectItem(null); break; case KeyCodes.KEY_ENTER: performItemCommand(item); preventEvent(event); break; } break; } } super.onBrowserEvent(event); }
Example 14
Source File: SimpleDayCell.java From calendar-component with Apache License 2.0 | 4 votes |
@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(); }
Example 15
Source File: SimpleDayCell.java From calendar-component with Apache License 2.0 | 4 votes |
@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; }
Example 16
Source File: DateCell.java From calendar-component with Apache License 2.0 | 4 votes |
private void handleEventRange(final MouseEvent event) { if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) { return; } if (eventRangeStart >= 0) { int newY = event.getY(); int fromY, toY; if (newY < eventRangeStart) { fromY = newY; toY = eventRangeStart; } else { fromY = eventRangeStart; toY = newY; } eventRangeStop = newY; Element main = getElement(); NodeList<Node> nodes = main.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Element c = (Element) nodes.getItem(i); if (Arrays.stream(slotElements).anyMatch(e -> e == c)) { int elemStart = c.getOffsetTop(); int elemStop = elemStart + getSlotHeight(); if (elemStart >= fromY && elemStart <= toY) { c.addClassName("v-daterange"); } else if (elemStop >= fromY && elemStop <= toY) { c.addClassName("v-daterange"); } else if (elemStop >= fromY && elemStart <= toY) { c.addClassName("v-daterange"); } else { c.removeClassName("v-daterange"); } } } } event.preventDefault(); }
Example 17
Source File: DateCell.java From calendar-component with Apache License 2.0 | 4 votes |
@Override @SuppressWarnings("deprecation") public void onMouseUp(MouseUpEvent event) { if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) { return; } Event.releaseCapture(getElement()); setFocus(false); // Drag initialized? if (eventRangeStart >= 0) { Element main = getElement(); if (eventRangeStart > eventRangeStop) { if (eventRangeStop <= -1) { eventRangeStop = 0; } int temp = eventRangeStart; eventRangeStart = eventRangeStop; eventRangeStop = temp; } // This happens for single clicks without dragging on the calendar if(eventRangeStart == eventRangeStop) { handleEventRange(event); } NodeList<Node> nodes = main.getChildNodes(); int slotStart = -1; int slotEnd = -1; // iterate over all child nodes, until we find first the start, // and then the end for (int i = 0; i < nodes.getLength(); i++) { Element element = (Element) nodes.getItem(i); boolean isRangeElement = element.getClassName().contains("v-daterange"); if (isRangeElement && slotStart == -1) { slotStart = i; slotEnd = i; // to catch one-slot selections } else if (isRangeElement) { slotEnd = i; } else if (slotStart != -1 && slotEnd != -1) { break; // FIXME ! is 'else if' right } } clearSelectionRange(); int startMinutes = firstHour * 60 + slotStart * 30; int endMinutes = (firstHour * 60) + (slotEnd + 1) * 30; Date currentDate = getDate(); if (weekgrid.getCalendar().getRangeSelectListener() != null) { SelectionRange weekSelection = new SelectionRange(); weekSelection.sMin = startMinutes; weekSelection.eMin = endMinutes; weekSelection.setStartDay(DateConstants.toRPCDate( currentDate.getYear(), currentDate.getMonth(), currentDate.getDate())); weekgrid.getCalendar().getRangeSelectListener().rangeSelected(weekSelection); } eventRangeStart = -1; } else { // Click event eventRangeStart = -1; cancelRangeSelect(); } }
Example 18
Source File: DateCellDayItem.java From calendar-component with Apache License 2.0 | 4 votes |
@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(); } }
Example 19
Source File: CirSim.java From circuitjs1 with GNU General Public License v2.0 | 4 votes |
public void onMouseDown(MouseDownEvent e) { // public void mousePressed(MouseEvent e) { e.preventDefault(); menuX = menuClientX = e.getX(); menuY = menuClientY = e.getY(); mouseDownTime = System.currentTimeMillis(); // maybe someone did copy in another window? should really do this when // window receives focus enablePaste(); if (e.getNativeButton() != NativeEvent.BUTTON_LEFT && e.getNativeButton() != NativeEvent.BUTTON_MIDDLE) return; // set mouseElm in case we are on mobile mouseSelect(e); mouseDragging=true; didSwitch = false; if (mouseWasOverSplitter) { tempMouseMode = MODE_DRAG_SPLITTER; return; } if (e.getNativeButton() == NativeEvent.BUTTON_LEFT) { // // left mouse tempMouseMode = mouseMode; if (e.isAltKeyDown() && e.isMetaKeyDown()) tempMouseMode = MODE_DRAG_COLUMN; else if (e.isAltKeyDown() && e.isShiftKeyDown()) tempMouseMode = MODE_DRAG_ROW; else if (e.isShiftKeyDown()) tempMouseMode = MODE_SELECT; else if (e.isAltKeyDown()) tempMouseMode = MODE_DRAG_ALL; else if (e.isControlKeyDown() || e.isMetaKeyDown()) tempMouseMode = MODE_DRAG_POST; } else tempMouseMode = MODE_DRAG_ALL; if ((scopeSelected != -1 && scopes[scopeSelected].cursorInSettingsWheel()) || ( scopeSelected == -1 && mouseElm instanceof ScopeElm && ((ScopeElm)mouseElm).elmScope.cursorInSettingsWheel())){ console("Doing something"); Scope s; if (scopeSelected != -1) s=scopes[scopeSelected]; else s=((ScopeElm)mouseElm).elmScope; s.properties(); clearSelection(); mouseDragging=false; return; } int gx = inverseTransformX(e.getX()); int gy = inverseTransformY(e.getY()); if (doSwitch(gx, gy)) { // do this BEFORE we change the mouse mode to MODE_DRAG_POST! Or else logic inputs // will add dots to the whole circuit when we click on them! didSwitch = true; return; } // IES - Grab resize handles in select mode if they are far enough apart and you are on top of them if (tempMouseMode == MODE_SELECT && mouseElm!=null && mouseElm.getHandleGrabbedClose(gx, gy, POSTGRABSQ, MINPOSTGRABSIZE) >=0 && !anySelectedButMouse() ) tempMouseMode = MODE_DRAG_POST; if (tempMouseMode != MODE_SELECT && tempMouseMode != MODE_DRAG_SELECTED) clearSelection(); pushUndo(); initDragGridX = gx; initDragGridY = gy; dragging = true; if (tempMouseMode !=MODE_ADD_ELM) return; // int x0 = snapGrid(gx); int y0 = snapGrid(gy); if (!circuitArea.contains(e.getX(), e.getY())) return; dragElm = constructElement(mouseModeStr, x0, y0); }
Example 20
Source File: VLayoutDragDropMouseHandler.java From cuba with Apache License 2.0 | 2 votes |
/** * Is the mouse down event a valid mouse drag event, i.e. left mouse button * is pressed without any modifier keys * * @param event * The mouse event * @return Is the mouse event a valid drag event */ private boolean isMouseDragEvent(NativeEvent event) { boolean hasModifierKey = event.getAltKey() || event.getCtrlKey() || event.getMetaKey() || event.getShiftKey(); return !(hasModifierKey || event.getButton() > NativeEvent.BUTTON_LEFT); }