当前位置: 首页>>代码示例>>Java>>正文


Java MouseEvent.consume方法代码示例

本文整理汇总了Java中javafx.scene.input.MouseEvent.consume方法的典型用法代码示例。如果您正苦于以下问题:Java MouseEvent.consume方法的具体用法?Java MouseEvent.consume怎么用?Java MouseEvent.consume使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.input.MouseEvent的用法示例。


在下文中一共展示了MouseEvent.consume方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPressed

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
private void onPressed(MouseEvent event) {
    if (event.getButton() == MouseButton.PRIMARY) {
        xAtPress = resizerComponent.xProperty().get();
        yAtPress = resizerComponent.yProperty().get();
        widthAtPress = resizerComponent.widthProperty().get();
        heightAtPress = resizerComponent.heightProperty().get();

        screenXAtPress = event.getScreenX();
        screenYAtPress = event.getScreenY();
        lastScreenX = screenXAtPress;
        lastScreenY = screenYAtPress;
        panXAtPress = panningComponent.panXProperty().get();
        panYAtPress = panningComponent.panYProperty().get();
        dragActive = true;
        if (onResizeStarted != null) {
            onResizeStarted.run();
        }
        event.consume();
    }
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:21,代码来源:ResizeBehavior.java

示例2: handle

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
@Override
public void handle(MouseEvent event) {

    // don't do anything if the user is in the process of adding to the selection model
    if( event.isControlDown() || event.isShiftDown()) {
        return;
    }

    Node node = (Node) event.getSource();

    dragContext.x = node.getTranslateX() - event.getSceneX();
    dragContext.y = node.getTranslateY() - event.getSceneY();

    // clear the model if the current node isn't in the selection => new selection
    if( !selectionModel.contains(node)) {
        selectionModel.clear();
        selectionModel.add( node);
    }

    // flag that the mouse released handler should consume the event, so it won't bubble up to the pane which has a rubberband selection mouse released handler
    enabled = true;

    // prevent rubberband selection handler
    event.consume();
}
 
开发者ID:lttng,项目名称:lttng-scope,代码行数:26,代码来源:ExampleMouseDrag2.java

示例3: press

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
private void press(MouseEvent e) {
  Node node = get();
  if (isEnable() && e.isConsumed() == false && node != null) {
    Corner corner = calcCorner(e);
    if (corner != Corner.CENTER) {
      pressedCorner = corner;
      startX = e.getScreenX();
      startY = e.getScreenY();
      startWidth = width.get() == -1 ? node.prefWidth(-1) : width.get();
      startHeight = height.get() == -1 ? node.prefHeight(-1) : height.get();
      startPosX = node.getLayoutX();
      startPosY = node.getLayoutY();
      e.consume();
    }
  }
}
 
开发者ID:XDean,项目名称:JavaFX-EX,代码行数:17,代码来源:ResizeSupport.java

示例4: drag

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
private void drag(MouseEvent e) {
  Node node = get();
  if (isEnable() && pressedCorner != null && e.isConsumed() == false && node != null) {
    double dx = e.getScreenX() - startX;
    if (pressedCorner.horizontal == HorizontalDirection.RIGHT) {
      width.set(MathUtil.toRange(startWidth + dx, minWidth.get(), maxWidth.get()));
    } else if (pressedCorner.horizontal == HorizontalDirection.LEFT) {
      width.set(MathUtil.toRange(startWidth - dx, minWidth.get(), maxWidth.get()));
      node.setLayoutX(startWidth + startPosX - width.get());
    }

    double dy = e.getScreenY() - startY;
    if (pressedCorner.vertical == VerticalDirection.DOWN) {
      height.set(MathUtil.toRange(startHeight + dy, minHeight.get(), maxHeight.get()));
    } else if (pressedCorner.vertical == VerticalDirection.UP) {
      height.set(MathUtil.toRange(startHeight - dy, minHeight.get(), maxHeight.get()));
      node.setLayoutY(startHeight + startPosY - height.get());
    }
    e.consume();
  }
}
 
开发者ID:XDean,项目名称:JavaFX-EX,代码行数:22,代码来源:ResizeSupport.java

示例5: switchDrag

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
private void switchDrag(MouseEvent event) {
    clearConner();
    drawConner();
    switch (cursor) {
        case C:
            x.set(event.getSceneX() - deltaX - getParent().getParent().getLayoutX());
            y.set(event.getSceneY() - deltaY -
                    getParent().getParent().getParent().getLayoutY()-getParent().getLayoutY());
            break;
        case L:
            x1.set(event.getX()-x.get());
            y1.set(event.getY()-y.get());
            break;
        case R:
            x2.set(event.getX()-x.get());
            y2.set(event.getY()-y.get());
            break;
    }
    event.consume();

}
 
开发者ID:xfangfang,项目名称:PhotoScript,代码行数:22,代码来源:DragBoxWithLine.java

示例6: onGraphPaneMouseDragged

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
/**
 * When dragging to drag on the graph pane.
 *
 * @param mouseEvent {@link MouseEvent} associated with the event
 */
@FXML
void onGraphPaneMouseDragged(final MouseEvent mouseEvent) {
    graphMovementCalculator.onMouseDragged(mouseEvent.getSceneX());
    ((Node) mouseEvent.getSource()).getScene().setCursor(Cursor.CLOSED_HAND);

    mouseEvent.consume();
}
 
开发者ID:ProgrammingLife2017,项目名称:hygene,代码行数:13,代码来源:GraphController.java

示例7: handle

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
/**
 * Moves the canvas within
 * @param event - event
 */
public void handle(MouseEvent event) {
    // right mouse button => panning
    if (!event.isSecondaryButtonDown()) {
        return;
    }

    double newX = sceneDragContext.translateAnchorX + event.getSceneX() - sceneDragContext.mouseAnchorX;
    double newY = sceneDragContext.translateAnchorY + event.getSceneY() - sceneDragContext.mouseAnchorY;

    canvas.setTranslateX(clamp(newX, minX(), maxX()));
    canvas.setTranslateY(clamp(newY, minY(), maxY()));

    event.consume();
}
 
开发者ID:INAETICS,项目名称:Drones-Simulator,代码行数:19,代码来源:SceneGestures.java

示例8: SimpleHSBColorPicker

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
public SimpleHSBColorPicker() {
    getChildren().addAll(hsbRect,lightRect);
    lightRect.setStroke(Color.GRAY);
    lightRect.setStrokeType(StrokeType.OUTSIDE);
    EventHandler<MouseEvent> ml = new EventHandler<MouseEvent>() {
        @Override public void handle(MouseEvent e) {
            double w = getWidth();
            double h = getHeight();
            double x = Math.min(w, Math.max(0, e.getX()));
            double y = Math.min(h, Math.max(0, e.getY()));
            double hue = (360/w)*x;
            double vert = (1/h)*y;
            double sat = 0;
            double bright = 0;
            if (vert<0.5) {
                bright = 1;
                sat = vert * 2;
            } else {
                bright = sat = 1- ((vert-0.5)*2);
            }
            // convert back to color
            Color c =  Color.hsb((int)hue,sat,bright);
            color.set(c);
            e.consume();
        }
    };
    lightRect.setOnMouseDragged(ml);
    lightRect.setOnMouseClicked(ml);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:30,代码来源:SimpleHSBColorPicker.java

示例9: switchPoint

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
private void switchPoint(MouseEvent event) {
    double tempX = event.getX();
    double tempY = event.getY();
    if (Math.abs(x1.get() + x.get() - tempX) < 10 && Math.abs(y1.get() + y.get() - tempY) < 10) {
        cursor = POINT.L;
        setCursor(Cursor.HAND);
    } else if (Math.abs(x2.get() + x.get() - tempX) < 10 && Math.abs(y2.get() + y.get() - tempY) < 10) {
        setCursor(Cursor.HAND);
        cursor = POINT.R;
    } else {
        cursor = POINT.C;
        setCursor(Cursor.CROSSHAIR);
    }
    event.consume();
}
 
开发者ID:xfangfang,项目名称:PhotoScript,代码行数:16,代码来源:DragBoxWithLine.java

示例10: dragStart

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
private void dragStart (MouseEvent event) {
    Dragboard db = startDragAndDrop(TransferMode.MOVE);
    ClipboardContent cc = new ClipboardContent();
    db.setDragView(myFactory.getTransferImage(this), 0, 0);
    cc.putString(serialize(getItem(), getListView().getItems().indexOf(getItem())));
    db.setContent(cc);
    event.consume();
}
 
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:9,代码来源:WaveDragCell.java

示例11: press

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
@Override
public void press(MouseEvent e) {
  Node node = get();
  if (isEnable() && e.isConsumed() == false && node != null) {
    Bounds boundsInLocal = node.getBoundsInLocal();
    if (canDrag(node.screenToLocal(e.getScreenX(), e.getScreenY()), boundsInLocal.getMaxX(), boundsInLocal.getMaxY())) {
      startX = e.getScreenX() - node.getLayoutX();
      startY = e.getScreenY() - node.getLayoutY();
      e.consume();
      pressed = true;
    }
  }
}
 
开发者ID:XDean,项目名称:JavaFX-EX,代码行数:14,代码来源:DragSupport.java

示例12: targetSetOnMouseDragged

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
private void targetSetOnMouseDragged(ScreenMap target, MouseEvent e, Queue<GamePoint> newPath) {
	Point2D point = target.sceneToLocal(e.getSceneX(), e.getSceneY());
	double mouseX = point.getX();
	double mouseY = point.getY();
	GamePoint coords = target.getCoordOfMouseHover(mouseX, mouseY);
	GamePoint actualGameLocation = target.getActualLocationOfSprite(coords);
	if (!coordAlreadyInPath(actualGameLocation, newPath)) {
		newPath.add(actualGameLocation);
		target.addBorderToCoordinate(coords);
	}
	
	e.consume();
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:14,代码来源:PathCreator.java

示例13: onMouseDragged

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
private void onMouseDragged(MouseEvent event) {
    if (event.getButton() == MouseButton.PRIMARY) {
        if (dragActive && (inertiaOvercome || isDraggedFarEnoughToOvercomeInertia(event.getScreenX(), event.getScreenY()))) {
            inertiaOvercome = true;
            lastScreenX = event.getScreenX();
            lastScreenY = event.getScreenY();
            if (onDragged != null) {
                onDragged.accept(calculateDragDelta());
            }
            panIfOutsideAxisBounds(event);
        }
        event.consume();
    }
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:15,代码来源:DragBehavior.java

示例14: processHide

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
/**
 * Update hide status.
 */
private void processHide(@NotNull final MouseEvent event) {
    event.consume();

    if (event.getButton() != MouseButton.PRIMARY) {
        return;
    }

    processHideImpl();
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:13,代码来源:AbstractListCell.java

示例15: onViewSequence

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
/**
 * When the user clicks on the view sequence {@link javafx.scene.control.Button}.
 *
 * @param event the {@link MouseEvent}
 */
@FXML
void onViewSequence(final MouseEvent event) {
    sequenceVisualizer.getVisibleProperty().set(!sequenceVisualizer.getVisibleProperty().get());
    event.consume();
}
 
开发者ID:ProgrammingLife2017,项目名称:hygene,代码行数:11,代码来源:NodePropertiesController.java


注:本文中的javafx.scene.input.MouseEvent.consume方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。