javafx.scene.input.MouseEvent#getClickCount ( )源码实例Demo

下面列出了javafx.scene.input.MouseEvent#getClickCount ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: OpenLabeler   文件: ObjectTag.java
@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);
}
 
源代码2 项目: mars-sim   文件: WebEventDispatcher.java
@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);
}
 
源代码3 项目: chat-socket   文件: FriendListWindow.java
@FXML
private void onListViewItemClick(MouseEvent event) {
    if (event.getClickCount() == 2) {
        Profile selectedItem = friendListView.getSelectionModel().getSelectedItem();
        if (friendButtonClickListener != null && selectedItem != null)
            friendButtonClickListener.call(selectedItem);
    }
}
 
源代码4 项目: archivo   文件: RecordingListController.java
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();
        }
    }
}
 
源代码5 项目: erlyberly   文件: SeqTraceView.java
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);
            }
        }
    }
}
 
源代码6 项目: Open-Lowcode   文件: CActionButton.java
@Override
public void handle(MouseEvent event) {
	// in case of double click, causes issues
	if (event.getClickCount() == 1)
		pageactionmanager.getMouseHandler().handle(event);

}
 
源代码7 项目: Open-Lowcode   文件: CGrid.java
@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);
				}
			}
	}
}
 
源代码8 项目: chart-fx   文件: DragResizerUtil.java
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);
}
 
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();
		}
	}
}
 
源代码10 项目: BetonQuest-Editor   文件: ConversationController.java
@FXML private void clickPointedBy(MouseEvent event) {
	try {
		if (event.getClickCount() == 2) {
			selectOption(pointedByList.getSelectionModel().getSelectedItem());
		}
	} catch (Exception e) {
		ExceptionController.display(e);
	}
}
 
源代码11 项目: BetonQuest-Editor   文件: ConversationController.java
@FXML private void clickPointsTo(MouseEvent event) {
	try {
		if (event.getClickCount() == 2) {
			selectOption(pointsToList.getSelectionModel().getSelectedItem());
		}
	} catch (Exception e) {
		ExceptionController.display(e);
	}
}
 
源代码12 项目: mars-sim   文件: ScenarioEditorController.java
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);
}
 
源代码13 项目: marathonv5   文件: RFXComponent.java
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);
    }
}
 
源代码14 项目: GMapsFX   文件: GoogleMapView.java
@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);
}
 
源代码15 项目: phoebus   文件: ListMultiOrderedPickerController.java
/**
 * Moves the selected item/s from the available list to the selected list
 */
@FXML
public void doubleClickSelect(MouseEvent e) {
    if (e.getClickCount() == 2) {
        moveRigth();
    }
}
 
源代码16 项目: DeskChan   文件: ControlsPanel.java
@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);
	}
}
 
源代码17 项目: gef   文件: CreateCurveOnDragHandler.java
@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());
		}
	}
}
 
源代码18 项目: phoebus   文件: ImagePlot.java
/** 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);
}
 
源代码19 项目: phoebus   文件: FileBrowserController.java
@FXML
public void handleMouseClickEvents(final MouseEvent event)
{
    if (event.getClickCount() == 2)
        openSelectedResources();
}
 
源代码20 项目: gef   文件: FocusAndSelectOnClickHandler.java
/**
 * 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;
}