Java Code Examples for com.google.gwt.event.dom.client.MouseDownEvent#getNativeButton()

The following examples show how to use com.google.gwt.event.dom.client.MouseDownEvent#getNativeButton() . 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: DiagramController.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void onMouseDown(MouseDownEvent event) {
	// Test if Right Click
	if (event.getNativeButton() == NativeEvent.BUTTON_RIGHT) {
		return;
	}

	if (inEditionSelectableShapeToDrawConnection) {
		inDragBuildArrow = true;
		inEditionSelectableShapeToDrawConnection = false;
		drawBuildArrow(startFunctionWidget, mousePoint);
		return;
	}

	if (inEditionDragMovablePoint) {
		inDragMovablePoint = true;
		inEditionDragMovablePoint = false;
		movablePoint = highlightConnection.addMovablePoint(highlightPoint);
		highlightConnection.setSynchronized(false);
		highlightConnection.setAllowSynchronized(false);
		movablePoint.setTrackPoint(mousePoint);
		// Set canvas foreground to avoid dragging over a widget
		topCanvas.setForeground();
		return;
	}
}
 
Example 2
Source File: GanttWidget.java    From gantt with Apache License 2.0 6 votes vote down vote up
@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: DateCell.java    From calendar-component with Apache License 2.0 5 votes vote down vote up
@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 4
Source File: PanListener.java    From djvu-html5 with GNU General Public License v2.0 5 votes vote down vote up
@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 5
Source File: FocusFrameController.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@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 6
Source File: MenuController.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@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 7
Source File: CollapseController.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onMouseDown(MouseDownEvent event, Element source) {
  if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
    return false;
  }
  handleClick(panel.fromToggle(source));
  return false;
}
 
Example 8
Source File: SvgArrowWidget.java    From gantt with Apache License 2.0 5 votes vote down vote up
@Override
public void onMouseDown(MouseDownEvent event) {
    if (event.getNativeButton() == NativeEvent.BUTTON_LEFT) {
        GWT.log("Starting point Clicked!");

        handleDownEvent(event.getNativeEvent());
    }
}
 
Example 9
Source File: FocusFrameController.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
@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: MenuController.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
@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 11
Source File: CollapseController.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onMouseDown(MouseDownEvent event, Element source) {
  if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
    return false;
  }
  handleClick(panel.fromToggle(source));
  return false;
}
 
Example 12
Source File: CirSim.java    From circuitjs1 with GNU General Public License v2.0 4 votes vote down vote up
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 13
Source File: DiagramController.java    From EasyML with Apache License 2.0 4 votes vote down vote up
/**
 * Trigger action when mouse down event fired
 * 
 * @param event
 */
public void onMouseDown(MouseDownEvent event) {
	logger.info("diagram left mouse down");
	this.getWidgetPanel().getElement().focus();
	if (event.getNativeButton() == NativeEvent.BUTTON_RIGHT) {
		NodeShape shape = (NodeShape) getShapeUnderMouse();
		if (shape instanceof OutNodeShape) {
			OutNodeShape outShape = (OutNodeShape)shape;
			int x = outShape.getOffsetLeft() + 2*outShape.getRadius();
			int y = outShape.getOffsetTop() + 2*outShape.getRadius();
			outShape.getContextMenu().setPopupPosition(x,y);
			outShape.getContextMenu().show();
		}
		if(isvacancy){
			event.stopPropagation();
			event.preventDefault();
			//Popup connection menu
			if( !this.inShapeArea ){
				final Connection c = getConnectionNearMouse();
				if (c != null) {
					showMenu(c);
				}else{
					showContextualMenu(event);
				}
			}

		}

		return;
	}

	if (!lockDrawConnection && inEditionToDrawConnection) {
		logger.info( "draw connection lock: " +  lockDrawConnection );
		inDragBuildConnection = true;
		inEditionToDrawConnection = false;
		((NodeShape) startShape).onConnectionStart();
		drawBuildArrow(startShape, getMousePoint());
	}
	if(!isvacancy){
		event.stopPropagation();
		event.preventDefault();
		focusTimer.scheduleRepeating(50);
	}
	else {
		this.clearSelectedWidgets();
		selectedWidget = null;
		focusTimer.scheduleRepeating(50);
	}
	this.setIsVacancy(true);
}