Java Code Examples for javafx.scene.input.MouseEvent#getClickCount()

The following examples show how to use javafx.scene.input.MouseEvent#getClickCount() . 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: ConversationController.java    From BetonQuest-Editor with GNU General Public License v3.0 5 votes vote down vote up
@FXML private void clickPointsTo(MouseEvent event) {
	try {
		if (event.getClickCount() == 2) {
			selectOption(pointsToList.getSelectionModel().getSelectedItem());
		}
	} catch (Exception e) {
		ExceptionController.display(e);
	}
}
 
Example 2
Source File: ControlsPanel.java    From DeskChan with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void handle(MouseEvent click) {
	if (click.getClickCount() == 2) {
		String item = registeredPanelsListView.getSelectionModel().getSelectedItem();
		item = item.substring(1 + item.lastIndexOf('('), item.length() - 1);
		open(item);
	}
}
 
Example 3
Source File: ListMultiOrderedPickerController.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Moves the selected item/s from the available list to the selected list
 */
@FXML
public void doubleClickSelect(MouseEvent e) {
    if (e.getClickCount() == 2) {
        moveRigth();
    }
}
 
Example 4
Source File: GoogleMapView.java    From GMapsFX with Apache License 2.0 5 votes vote down vote up
@Override
public Event dispatchEvent(Event event, EventDispatchChain tail) {

    if (event instanceof MouseEvent) {
        MouseEvent mouseEvent = (MouseEvent) event;
        if (mouseEvent.getClickCount() > 1) {
            if (disableDoubleClick) {
                mouseEvent.consume();
            }
        }
    }
    return originalDispatcher.dispatchEvent(event, tail);
}
 
Example 5
Source File: RFXComponent.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
protected void mousePressed(MouseEvent me) {
    if (me.isPrimaryButtonDown() && me.getClickCount() == 1 && !me.isAltDown() && !me.isMetaDown() && !me.isControlDown()) {
        mouseButton1Pressed(me);
    } else {
        recorder.recordClick2(this, me, true);
    }
}
 
Example 6
Source File: ScenarioEditorController.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
private void createLaunchAppEvent(final TableView<Scenario> tableView) {
    
    EventHandler<MouseEvent> x =
            new EventHandler<MouseEvent>(){
            public void handle(MouseEvent event){
                if (event.getClickCount() == 2) {
                    final Scenario recipe = tableView.getSelectionModel().getSelectedItem();
                    Platform.runLater(new Runnable() {
                        @Override
                        public void run() {
                            Stage stage = new Stage();
                            
                            try {
                                Class<?> appClass = Class.forName(recipe.getFullClassName());
                                Object object = appClass.newInstance();
                                if (object instanceof Application) {
                                    Application app = (Application) object;
                                    app.start(stage);
                                } else {
                                    Method mainMethod = appClass.getDeclaredMethod("main", new Class[]{String[].class});
                                    String[] argu = null;
                                    mainMethod.invoke(object, new Object[]{argu});
                                }
                                
                            } catch (Exception e) {
                                e.printStackTrace();

                            }
                        }
                    });
                }
            }
        };
    tableView.setOnMouseClicked(x);
}
 
Example 7
Source File: ObjectTag.java    From OpenLabeler with Apache License 2.0 5 votes vote down vote up
@Override
protected void onMouseClicked(MouseEvent me) {
    if (me.getClickCount() != 2 || !name.localToScreen(name.getBoundsInLocal()).contains(me.getScreenX(), me.getScreenY())) {
        return;
    }
    setSelected(true);
    NameEditor editor = new NameEditor(nameProperty().get());
    String label = editor.showPopup(me.getScreenX(), me.getScreenY(), getScene().getWindow());
    nameProperty().set(label);
    Settings.recentNamesProperty.addName(label);
}
 
Example 8
Source File: ConversationController.java    From BetonQuest-Editor with GNU General Public License v3.0 5 votes vote down vote up
@FXML private void clickPointedBy(MouseEvent event) {
	try {
		if (event.getClickCount() == 2) {
			selectOption(pointedByList.getSelectionModel().getSelectedItem());
		}
	} catch (Exception e) {
		ExceptionController.display(e);
	}
}
 
Example 9
Source File: JFXMouseDoubleClickListenerManager.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void handle(MouseEvent event) {
	if(!this.control.isIgnoreEvents()) {
		if( event.getButton().equals(MouseButton.PRIMARY) && event.getClickCount() == 2 ){
			this.onMouseDoubleClick(new UIMouseEvent(this.control, new UIPosition((float)event.getX(), (float)event.getY()), JFXMouseButton.getMouseButton(event.getButton())));
			
			event.consume();
		}
	}
}
 
Example 10
Source File: DragResizerUtil.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
protected void resetNodeSize(final MouseEvent evt) {
    if (!evt.isPrimaryButtonDown() || evt.getClickCount() < 2) {
        return;
    }

    if (!(node instanceof Region)) {
        return;
    }

    ((Region) node).setPrefWidth(Region.USE_COMPUTED_SIZE);
    ((Region) node).setPrefHeight(Region.USE_COMPUTED_SIZE);
}
 
Example 11
Source File: CGrid.java    From Open-Lowcode with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void handle(MouseEvent event) {
	MouseButton button = event.getButton();

	if (button == MouseButton.PRIMARY) {
		if (event.getClickCount() == 1 && (event.isShiftDown())) {

			if (thisobjectgrid.isinlineupdate)
				if (!thisobjectgrid.updatemodeactive) { // currently, table in read mode, move to
					logger.fine("moving tableview " + thisobjectgrid.name + " to update mode");
					thisobjectgrid.tableview.setEditable(true);
					thisobjectgrid.tableview.getSelectionModel().setCellSelectionEnabled(true);
					thisobjectgrid.updatemodeactive = true;
					thisobjectgrid.startupdate.setDisable(true);
					thisobjectgrid.commitupdate.setDisable(false);
					return;
				}
		}
		if (thisobjectgrid.isinlineupdate)
			if (thisobjectgrid.updatemodeactive)
				if (event.getClickCount() == 1) {
					if (thisobjectgrid.tableview.getEditingCell() == null) {
						@SuppressWarnings("unchecked")
						TablePosition<CObjectGridLine<String>, ?> focusedCellPosition = thisobjectgrid.tableview
								.getFocusModel().getFocusedCell();
						thisobjectgrid.tableview.edit(focusedCellPosition.getRow(),
								focusedCellPosition.getTableColumn());

					}
				}
		if (thisobjectgrid.iscellaction)
			if (event.getClickCount() > 1) {
				// trigger the action on double click only if updatemode is not active
				if (!thisobjectgrid.updatemodeactive) {
					logger.info("Single action click detected");
					pageactionmanager.getMouseHandler().handle(event);
				}
			}
	}
}
 
Example 12
Source File: CActionButton.java    From Open-Lowcode with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void handle(MouseEvent event) {
	// in case of double click, causes issues
	if (event.getClickCount() == 1)
		pageactionmanager.getMouseHandler().handle(event);

}
 
Example 13
Source File: SeqTraceView.java    From erlyberly with GNU General Public License v3.0 5 votes vote down vote up
private void onTraceClicked(MouseEvent me) {
    if(me.getButton().equals(MouseButton.PRIMARY)) {
        if(me.getClickCount() == 2) {
            SeqTraceLog selectedItem = table.getSelectionModel().getSelectedItem();

            if(selectedItem != null) {
                showTraceTermView(selectedItem);
            }
        }
    }
}
 
Example 14
Source File: RecordingListController.java    From archivo with GNU General Public License v3.0 5 votes vote down vote up
private void archiveOnDoubleClick(MouseEvent event) {
    if (event.getButton() == MouseButton.PRIMARY && event.getClickCount() > 1) {
        int numRecordings = recordingSelection.getRecordingsWithChildren().size();
        // If the user double-clicks a group header, just expand/collapse it, don't archive everything in it
        if (recordingSelection.isArchivableProperty().get() && numRecordings == 1) {
            mainApp.archiveSelection();
        }
    }
}
 
Example 15
Source File: FriendListWindow.java    From chat-socket with MIT License 5 votes vote down vote up
@FXML
private void onListViewItemClick(MouseEvent event) {
    if (event.getClickCount() == 2) {
        Profile selectedItem = friendListView.getSelectionModel().getSelectedItem();
        if (friendButtonClickListener != null && selectedItem != null)
            friendButtonClickListener.call(selectedItem);
    }
}
 
Example 16
Source File: WebEventDispatcher.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Event dispatchEvent(Event event, EventDispatchChain tail) {

	if (event instanceof MouseEvent){
        MouseEvent m = (MouseEvent)event;
        if (event.getEventType().equals(MouseEvent.MOUSE_CLICKED) ||
            event.getEventType().equals(MouseEvent.MOUSE_PRESSED)) {
            Point2D origin = new Point2D(m.getX(),m.getY());
            if (limit != null)
            	allowDrag = !(origin.getX() < limit.getX() && origin.getY() < limit.getY());
        }

        // avoid selection with mouse dragging, allowing dragging the scrollbars
        if (event.getEventType().equals(MouseEvent.MOUSE_DRAGGED)) {
            if(!allowDrag){
                event.consume();
            }
        }
        // Avoid selection of word, line, paragraph with mouse click
        if(m.getClickCount() > 1){
            event.consume();
        }
    }

    if (event instanceof KeyEvent && event.getEventType().equals(KeyEvent.KEY_PRESSED)){
        KeyEvent k = (KeyEvent)event;
        // Avoid copy with Ctrl+C or Ctrl+Insert
        if((k.getCode().equals(KeyCode.C) || k.getCode().equals(KeyCode.INSERT)) && k.isControlDown()){
            event.consume();
        }
        // Avoid selection with shift+Arrow
        if(k.isShiftDown() && (k.getCode().equals(KeyCode.RIGHT) || k.getCode().equals(KeyCode.LEFT) ||
            k.getCode().equals(KeyCode.UP) || k.getCode().equals(KeyCode.DOWN))){
            event.consume();
        }
    }
    return oldDispatcher.dispatchEvent(event, tail);
}
 
Example 17
Source File: CreateCurveOnDragHandler.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void startDrag(MouseEvent event) {
	// create new curve
	GeometricCurve curve = new GeometricCurve(new Point[] { new Point(), new Point() },
			MvcLogoExample.GEF_COLOR_GREEN, MvcLogoExample.GEF_STROKE_WIDTH, MvcLogoExample.GEF_DASH_PATTERN, null);
	curve.addSourceAnchorage(getShapePart().getContent());

	// create using CreationPolicy from root part
	CreationPolicy creationPolicy = getHost().getRoot().getAdapter(CreationPolicy.class);
	init(creationPolicy);
	curvePart = (GeometricCurvePart) creationPolicy.create(curve, getHost().getRoot(),
			HashMultimap.<IContentPart<? extends Node>, String> create());
	commit(creationPolicy);

	// disable refresh visuals for the curvePart
	storeAndDisableRefreshVisuals(curvePart);

	// move curve to pointer location
	curvePart.getVisual().setEndPoint(getLocation(event));

	// build operation to deselect all but the new curve part
	List<IContentPart<? extends Node>> toBeDeselected = new ArrayList<>(
			getHost().getRoot().getViewer().getAdapter(SelectionModel.class).getSelectionUnmodifiable());
	toBeDeselected.remove(curvePart);
	DeselectOperation deselectOperation = new DeselectOperation(getHost().getRoot().getViewer(), toBeDeselected);
	// execute on stack
	try {
		getHost().getRoot().getViewer().getDomain().execute(deselectOperation, new NullProgressMonitor());
	} catch (ExecutionException e) {
		throw new RuntimeException(e);
	}

	// find bend target part
	bendTargetPart = findBendTargetPart(curvePart, event.getTarget());
	if (bendTargetPart != null) {
		dragPolicies = bendTargetPart.getAdapters(ClickDragGesture.ON_DRAG_POLICY_KEY);
	}
	if (dragPolicies != null) {
		MouseEvent dragEvent = new MouseEvent(event.getSource(), event.getTarget(), MouseEvent.MOUSE_DRAGGED,
				event.getX(), event.getY(), event.getScreenX(), event.getScreenY(), event.getButton(),
				event.getClickCount(), event.isShiftDown(), event.isControlDown(), event.isAltDown(),
				event.isMetaDown(), event.isPrimaryButtonDown(), event.isMiddleButtonDown(),
				event.isSecondaryButtonDown(), event.isSynthesized(), event.isPopupTrigger(),
				event.isStillSincePress(), event.getPickResult());
		for (IOnDragHandler dragPolicy : dragPolicies.values()) {
			dragPolicy.startDrag(event);
			// XXX: send initial drag event so that the end position is set
			dragPolicy.drag(dragEvent, new Dimension());
		}
	}
}
 
Example 18
Source File: ImagePlot.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
/** onMousePressed */
private void mouseDown(final MouseEvent e)
{
    // Don't start mouse actions when user invokes context menu
    if (! e.isPrimaryButtonDown()  ||  (PlatformInfo.is_mac_os_x && e.isControlDown()))
        return;

    // Received a click while a tacker is active
    // -> User clicked outside of tracker. Remove it.
    if (roi_tracker != null)
    {
        removeROITracker();
        // Don't cause accidental 'zoom out' etc.
        // User needs to click again for that.
        return;
    }

    // Select any tracker
    final Point2D current = new Point2D(e.getX(), e.getY());
    for (RegionOfInterest roi : rois)
        if (roi.isVisible()  &&  roi.isInteractive())
        {
            final Rectangle rect = roiToScreen(roi);
            if (rect.contains(current.getX(), current.getY()))
            {   // Check if complete ROI is visible,
                // because otherwise tracker would extend beyond the
                // current image viewport
                final Rectangle2D image_rect = GraphicsUtils.convert(image_area);
                if (image_rect.contains(rect.x, rect.y, rect.width, rect.height))
                {
                    roi_tracker = new Tracker(image_rect);
                    roi_tracker.setPosition(rect.x, rect.y, rect.width, rect.height);
                    ChildCare.addChild(getParent(), roi_tracker);
                    final int index = rois.indexOf(roi);
                    roi_tracker.setListener((old_pos, new_pos) -> updateRoiFromScreen(index, new_pos));
                    return;
                }
            }
        }

    mouse_start = mouse_current = Optional.of(current);

    final int clicks = e.getClickCount();

    if (mouse_mode == MouseMode.NONE)
    {
        if (crosshair)
        {
            updateLocationInfo(e.getX(), e.getY());
            requestRedraw();
        }
    }
    else if (mouse_mode == MouseMode.PAN)
    {   // Determine start of 'pan'
        mouse_start_x_range = x_axis.getValueRange();
        mouse_start_y_range = y_axis.getValueRange();
        mouse_mode = MouseMode.PAN_PLOT;
    }
    else if (mouse_mode == MouseMode.ZOOM_IN  &&  clicks == 1)
    {   // Determine start of 'rubberband' zoom.
        // Reset cursor from SIZE* to CROSS.
        if (y_axis.getBounds().contains(current.getX(), current.getY()))
        {
            mouse_mode = MouseMode.ZOOM_IN_Y;
            PlotCursors.setCursor(this, mouse_mode);
        }
        else if (image_area.contains(current.getX(), current.getY()))
        {
            mouse_mode = MouseMode.ZOOM_IN_PLOT;
            PlotCursors.setCursor(this, mouse_mode);
        }
        else if (x_axis.getBounds().contains(current.getX(), current.getY()))
        {
            mouse_mode = MouseMode.ZOOM_IN_X;
            PlotCursors.setCursor(this, mouse_mode);
        }
    }
    else if ((mouse_mode == MouseMode.ZOOM_IN && clicks == 2)  ||  mouse_mode == MouseMode.ZOOM_OUT)
        zoomInOut(current.getX(), current.getY(), ZOOM_FACTOR);
}
 
Example 19
Source File: FileBrowserController.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
@FXML
public void handleMouseClickEvents(final MouseEvent event)
{
    if (event.getClickCount() == 2)
        openSelectedResources();
}
 
Example 20
Source File: FocusAndSelectOnClickHandler.java    From gef with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Returns <code>true</code> if the given {@link MouseEvent} should trigger
 * focus and select. Otherwise returns <code>false</code>. Per default
 * returns <code>true</code> if a single mouse click is performed.
 *
 * @param event
 *            The {@link MouseEvent} in question.
 * @return <code>true</code> if the given {@link MouseEvent} should trigger
 *         focus and select, otherwise <code>false</code>.
 */
protected boolean isFocusAndSelect(MouseEvent event) {
	return event.getClickCount() <= 1;
}