com.google.gwt.event.dom.client.MouseDownEvent Java Examples

The following examples show how to use com.google.gwt.event.dom.client.MouseDownEvent. 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: TableOrder.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void onMouseDown(MouseDownEvent event) {
	this.onMouseUp(null);

	Icon dragIcon = (Icon) event.getSource();
	this.selectedRow = (TableRow<T>) dragIcon.getParent().getParent();
	this.body = (TableEditorBody<T>) this.selectedRow.getParent();

	this.overRegistration = new HandlerRegistrationCollection();
	this.upRegistration = RootPanel.get().addDomHandler(this, MouseUpEvent.getType());
	this.rows = Lists.newArrayList(this.body.getRows());
	for (TableRow<T> row : this.rows) {
		this.overRegistration.add(row.addDomHandler(this, MouseOverEvent.getType()));
	}
	TableOrder.this.disableTextSelection(true);
	RootPanel.get().getElement().getStyle().setCursor(Style.Cursor.MOVE);
	StyleUtils.addStyle(this.selectedRow, TableOrder.STYLE_ROW_DRAGING);
}
 
Example #2
Source File: Leaf.java    From EasyML with Apache License 2.0 6 votes vote down vote up
/**
 * Create a leaf node for the Tree
 *
 * @param name   name of the TreeItem
 * @param module Attached moduleId for the TreeItem
 */
public Leaf(String name,
		T module,
		String style) {
	// add context menu
	this.menu = new ContextMenu();
	label = new Label(name);
	this.setWidget(label);

	label.addMouseDownHandler(new MouseDownHandler() {
		@Override
		public void onMouseDown(MouseDownEvent event) {
			// display the context menu when right click
			if (event.getNativeButton() == NativeEvent.BUTTON_RIGHT) {
				menu.setPopupPosition(event.getClientX(), event.getClientY());
				menu.show();
			}
		}
	});

	// set moduleId
	this.module = module;
	this.addStyleName("bda-treeleaf");
	if (!style.equals(""))
		this.addStyleName(style);
}
 
Example #3
Source File: DiagramController.java    From EasyML with Apache License 2.0 6 votes vote down vote up
/**
 * Show the context menu of the mouse position.(Position from mouse down event)
 * 
 * @param event  mouse down event.
 */
public void showContextualMenu(MouseDownEvent event){
	final int X = event.getRelativeX(widgetPanel.getElement());
	final int Y = event.getRelativeY(widgetPanel.getElement());
	getMousePoint().setLeft(X);
	getMousePoint().setTop(Y);

	final int offsetX = event.getClientX();
	final int offsetY = event.getClientY();
	mouseOffsetPoint.setLeft(offsetX);
	mouseOffsetPoint.setTop(offsetY);

	cmenu.hide();
	cmenu = new ContextMenu();
	Command command = new Command() {
		@Override
		public void execute() {
			cmenu.hide();
		}
	};
}
 
Example #4
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 #5
Source File: VComboBoxMultiselect.java    From vaadin-combobox-multiselect with Apache License 2.0 6 votes vote down vote up
@Override
public void onMouseDown(MouseDownEvent event) {
	debug("VComboBoxMultiselect.onMouseDown(): blocking mouseDown event to avoid blur");

	event.preventDefault();
	event.stopPropagation();

	/*
	 * In IE the above wont work, the blur event will still trigger. So, we
	 * set a flag here to prevent the next blur event from happening. This
	 * is not needed if do not already have focus, in that case there will
	 * not be any blur event and we should not cancel the next blur.
	 */
	if (BrowserInfo.get()
		.isIE() && this.focused) {
		this.preventNextBlurEventInIE = true;
		debug("VComboBoxMultiselect: Going to prevent next blur event on IE");
	}
}
 
Example #6
Source File: VLayoutDragDropMouseHandler.java    From cuba with Apache License 2.0 6 votes vote down vote up
/**
 * Start listening to events
 */
private void attach() {
    if (handlers.isEmpty()) {
        if (attachTarget == null) {
            handlers.add(
                    root.addDomHandler(this, MouseDownEvent.getType()));
            handlers.add(
                    root.addDomHandler(this, TouchStartEvent.getType()));
        } else {
            handlers.add(attachTarget.addDomHandler(this,
                    MouseDownEvent.getType()));
            handlers.add(attachTarget.addDomHandler(this,
                    TouchStartEvent.getType()));
        }
    }
}
 
Example #7
Source File: VComboBoxMultiselect.java    From vaadin-combobox-multiselect with Apache License 2.0 6 votes vote down vote up
@Override
public void onMouseDown(MouseDownEvent event) {
	debug("VComboBoxMultiselect.onMouseDown(): blocking mouseDown event to avoid blur");

	event.preventDefault();
	event.stopPropagation();

	/*
	 * In IE the above wont work, the blur event will still trigger. So, we
	 * set a flag here to prevent the next blur event from happening. This
	 * is not needed if do not already have focus, in that case there will
	 * not be any blur event and we should not cancel the next blur.
	 */
	if (BrowserInfo.get()
		.isIE() && this.focused) {
		this.preventNextBlurEventInIE = true;
		debug("VComboBoxMultiselect: Going to prevent next blur event on IE");
	}
}
 
Example #8
Source File: RoomSharingWidget.java    From unitime with Apache License 2.0 6 votes vote down vote up
Cell(int day, int slot) {
	super("cell", "item", isEditable(day, slot) ? "clickable" : null);
	iDay = day; iSlot = slot;
	RoomSharingOption option = iModel.getOption(day, slot);
	if (option == null) {
		getElement().getStyle().clearBackgroundColor();
		setHTML("");
		setTitle("");
	} else {
		getElement().getStyle().setBackgroundColor(option.getColor());
		setHTML(option.getCode() == null ? "" : option.getCode());
		setTitle(CONSTANTS.longDays()[day] + " " + slot2short(slot) + " - " + slot2short(slot + iMode.getStep()) + ": " + option.getName());
	}
	if (isEditable(day, slot))
		addMouseDownHandler(new MouseDownHandler() {
			@Override
			public void onMouseDown(MouseDownEvent event) {
				setOption(iOption);
			}
		});
}
 
Example #9
Source File: PeriodPreferencesWidget.java    From unitime with Apache License 2.0 6 votes vote down vote up
Cell(int day, int slot, Date date, PeriodInterface period) {
	super("cell", "item", isEditable() && period != null ? "clickable" : null, period == null ? "disabled" : null, period != null && iModel.isAssigned(period) ? "highlight" : null);
	iDay = day;
	iSlot = slot;
	iDate = date;
	iPeriod = period;
	if (period != null) {
		PreferenceInterface preference = iModel.getPreference(day, slot);
		if (preference == null) {
			getElement().getStyle().clearBackgroundColor();
			setHTML("");
			setTitle("");
		} else {
			getElement().getStyle().setBackgroundColor(preference.getColor());
			setTitle(DateTimeFormat.getFormat(CONSTANTS.examPeriodDateFormat()).format(date) + " " + slot2short(slot) + (period == null ? "" : " - " + slot2short(slot + period.getLength())) + ": " + preference.getName());
		}
		if (isEditable())
			addMouseDownHandler(new MouseDownHandler() {
				@Override
				public void onMouseDown(MouseDownEvent event) {
					setOption(iPreference);
				}
			});				
	}
}
 
Example #10
Source File: PeriodPreferencesWidget.java    From unitime with Apache License 2.0 6 votes vote down vote up
private D(int day, int slot, Date date, PeriodInterface period) {
	super("cell", "day", isEditable() && period != null ? "clickable" : null, period == null ? "unavailable" : null);
	iDay = day;
	iSlot = slot;
	iDate = date;
	iPeriod = period;
	setText(DateTimeFormat.getFormat("d").format(date));
	if (period != null) {
		PreferenceInterface preference = iModel.getPreference(day, slot);
		if (preference == null) {
			getElement().getStyle().clearBackgroundColor();
			setTitle("");
		} else {
			getElement().getStyle().setBackgroundColor(preference.getColor());
			setTitle(DateTimeFormat.getFormat(CONSTANTS.examPeriodDateFormat()).format(date) + " " + slot2short(slot) + (period == null ? "" : " - " + slot2short(slot + period.getLength())) + ": " + preference.getName());
		}
		if (isEditable())
			addMouseDownHandler(new MouseDownHandler() {
				@Override
				public void onMouseDown(MouseDownEvent event) {
					setOption(iPreference);
				}
			});				
	}
}
 
Example #11
Source File: SvgArrowWidget.java    From gantt with Apache License 2.0 6 votes vote down vote up
@Override
public void setUpEventHandlers(boolean touchSupported,
        boolean msTouchSupported) {
    this.touchSupported = touchSupported;
    this.msTouchSupported = msTouchSupported;
    if (msTouchSupported) {
        addDomHandler(pointerDownHandler, PointerDownEvent.getType());
        addDomHandler(pointerUpHandler, PointerUpEvent.getType());
    } else if (touchSupported) {
        addDomHandler(touchStartHandler, TouchStartEvent.getType());
    } else {
        addHandler(mouseDownHandler, MouseDownEvent.getType());
    }
    registerMouseDownAndTouchDownEventListener(startingPoint);
    registerMouseDownAndTouchDownEventListener(endingPoint);
}
 
Example #12
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 #13
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 #14
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 #15
Source File: VLayoutDragDropMouseHandler.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onMouseDown(MouseDownEvent event) {
    NativeEvent nativeEvent = event.getNativeEvent();
    if (isElementNode(nativeEvent) && isChildOfRoot(nativeEvent)) {
        if (startDragOnMove) {
            initiateDragOnMove(event.getNativeEvent());
        } else {
            initiateDrag(event.getNativeEvent());
        }
    }
}
 
Example #16
Source File: SimplePaletteItem.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
private void addHandlers() {
  addMouseDownHandler(new MouseDownHandler() {
    @Override
    public void onMouseDown(MouseDownEvent arg0) {
      select(getWidget());
    }
  });
  addTouchStartHandler(new TouchStartHandler() {
    @Override
    public void onTouchStart(TouchStartEvent event) {
      select(getWidget());
    }
  });
}
 
Example #17
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 #18
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 #19
Source File: TravelTimes.java    From unitime with Apache License 2.0 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	switch (DOM.eventGetType(event)) {
    case Event.ONMOUSEDOWN:
    	MouseDownEvent.fireNativeEvent(event, this);
    	event.stopPropagation();
    	event.preventDefault();
    	break;
	}
}
 
Example #20
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 #21
Source File: IntervalSelector.java    From unitime with Apache License 2.0 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	switch (DOM.eventGetType(event)) {
    case Event.ONMOUSEDOWN:
    	MouseDownEvent.fireNativeEvent(event, this);
    	event.stopPropagation();
    	event.preventDefault();
    	break;
	}
}
 
Example #22
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 #23
Source File: TimeGrid.java    From unitime with Apache License 2.0 5 votes vote down vote up
public SelectionPanel(boolean fixed) {
	setStyleName(fixed ? "selection" : "active-selection");
	if (fixed) {
		iRemove = new P("x"); iRemove.setHTML("&times;");
		iRemove.addMouseDownHandler(new MouseDownHandler() {
			@Override
			public void onMouseDown(MouseDownEvent event) {
				iSelections.remove(SelectionPanel.this);
				if (iSelection != null)
					iAllSelections.remove(iSelection);
			}
		});
		if (iRTL) {
			iRemove.getElement().getStyle().setLeft(2, Unit.PX);
		} else {
			iRemove.getElement().getStyle().setRight(2, Unit.PX);
		}
		iRemove.getElement().getStyle().setTop(2, Unit.PX);
		iRemove.getElement().getStyle().setPosition(Position.ABSOLUTE);
		add(iRemove);
		iText = new P("text");
		add(iText, 0, 0);
	}
	
	sinkEvents(Event.ONMOUSEDOWN);
	sinkEvents(Event.ONMOUSEUP);
	sinkEvents(Event.ONMOUSEMOVE);
}
 
Example #24
Source File: SingleDateSelector.java    From unitime with Apache License 2.0 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	switch (DOM.eventGetType(event)) {
    case Event.ONMOUSEDOWN:
    	MouseDownEvent.fireNativeEvent(event, this);
    	event.stopPropagation();
    	event.preventDefault();
    	break;
	}
}
 
Example #25
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 #26
Source File: SingleDateSelector.java    From unitime with Apache License 2.0 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	switch (DOM.eventGetType(event)) {
    case Event.ONMOUSEDOWN:
    	MouseDownEvent.fireNativeEvent(event, this);
    	event.stopPropagation();
    	event.preventDefault();
    	break;
	}
}
 
Example #27
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 #28
Source File: PanListener.java    From djvu-html5 with GNU General Public License v2.0 5 votes vote down vote up
public PanListener(Widget widget) {
	this.widget = widget;
	widget.addDomHandler(this, MouseDownEvent.getType());
	widget.addDomHandler(this, MouseUpEvent.getType());
	widget.addDomHandler(this, MouseMoveEvent.getType());
	widget.addDomHandler(this, TouchStartEvent.getType());
	widget.addDomHandler(this, TouchEndEvent.getType());
	widget.addDomHandler(this, TouchMoveEvent.getType());
}
 
Example #29
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 #30
Source File: TableOrder.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
TDHandle() {
	super(TableCellElement.TAG_TD);
	this.dragIcon = new Icon();
	this.dragIcon.setType(IconFont.ICON_DRAG);
	this.dragIcon.addDomHandler(TableOrder.this.mouseHandler, MouseDownEvent.getType());
	this.dragIcon.addDomHandler(TableOrder.this.mouseHandler, ClickEvent.getType());
	this.append(this.dragIcon);
}