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


Java MouseButton类代码示例

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


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

示例1: canvasClicked

import javafx.scene.input.MouseButton; //导入依赖的package包/类
@Override
public void canvasClicked(MouseEvent mouseEvent) {
	DrawCoords mousePosition = new DrawCoords(mouseEvent.getX(), mouseEvent.getY());
	CoordProjector projector = getProjector(boardCanvas);
	Coords boardPos = projector.nearestCoords(mousePosition);

	if ( !projector.isWithinBounds(mousePosition) )
		return;

	scorePane.enableButtons();
	if ( mouseEvent.getButton() == MouseButton.PRIMARY ) {
		if ( !mouseEvent.isShiftDown() )
			boardScorer.markGroupDead(boardPos);
		else
			boardScorer.unmarkGroupDead(boardPos);
	}
}
 
开发者ID:GoSuji,项目名称:Suji,代码行数:18,代码来源:Scoring.java

示例2: handle

import javafx.scene.input.MouseButton; //导入依赖的package包/类
@Override
public void handle(MouseEvent event) {
    if(event.getEventType()==MouseEvent.MOUSE_MOVED){
        move.handle(event.getX(),event.getY());
    }else if(event.getEventType()==MouseEvent.MOUSE_PRESSED){
        if(event.getButton()==MouseButton.PRIMARY){
            press.handle(event.getX(),event.getY());
        }else if(event.getButton()==MouseButton.SECONDARY){
            rightPress.handle(event.getX(),event.getY());
        }
    }else if(event.getEventType()==MouseEvent.MOUSE_RELEASED){
        if(event.getButton()==MouseButton.PRIMARY){
            release.handle(event.getX(),event.getY());
        }else if(event.getButton()==MouseButton.SECONDARY){
            rightRelease.handle(event.getX(),event.getY());
        }
    }
}
 
开发者ID:whitewoodcity,项目名称:xbrowser,代码行数:19,代码来源:MouseEventHandler.java

示例3: testGestureDisabling

import javafx.scene.input.MouseButton; //导入依赖的package包/类
@Test
public void testGestureDisabling() throws Exception {
	pane.setGestureEnabled(false);
	pane.zoomTo(2, pane.targetPointAtViewportCentre());
	Transform expected = target.captureTransform();
	FxRobot robot = new FxRobot();
	robot.moveTo(pane)
			.scroll(2, VerticalDirection.UP)
			.scroll(2, VerticalDirection.DOWN)
			.drag(MouseButton.PRIMARY).dropBy(100, 100);
	assertThat(target.captureTransform()).isEqualToComparingOnlyGivenFields(expected,
			"xx", "xy", "xz",
			"yx", "yy", "yz",
			"zx", "zy", "zz",
			"xt", "yt", "zt");
}
 
开发者ID:tom91136,项目名称:GestureFX,代码行数:17,代码来源:GesturePaneTest.java

示例4: ChildrenFileCell

import javafx.scene.input.MouseButton; //导入依赖的package包/类
public ChildrenFileCell() {
    addEventFilter(MouseEvent.MOUSE_CLICKED, (e) -> {
        if (fileChooserInfo.isFileCreation()) {
            return;
        }
        if (e.getButton() != MouseButton.PRIMARY || e.getClickCount() != 1) {
            return;
        }
        File selectedItem = childrenListView.getSelectionModel().getSelectedItem();
        if (selectedItem != null) {
            fileNameBox.clear();
            fileNameBox.setText(selectedItem.getName());
        } else {
            fileNameBox.clear();
        }

    });
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:19,代码来源:MarathonFileChooser.java

示例5: onMousePressed

import javafx.scene.input.MouseButton; //导入依赖的package包/类
private void onMousePressed(MouseEvent event) {
    // Don't start drag if shortcut is down because the node might be about to be deselected.
    if (event.getButton() == MouseButton.PRIMARY && !event.isShortcutDown()) {
        screenXAtPress = event.getScreenX();
        screenYAtPress = event.getScreenY();
        lastScreenX = screenXAtPress;
        lastScreenY = screenYAtPress;
        panXAtPress = panningComponent.panXProperty().get();
        panYAtPress = panningComponent.panYProperty().get();
        xAtPress = node.getLayoutX();
        yAtPress = node.getLayoutY();
        dragActive = true;
        inertiaOvercome = false;
        if (onDragStarted != null) {
            onDragStarted.run();
        }
        event.consume();
    }
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:20,代码来源:DragBehavior.java

示例6: onPressed

import javafx.scene.input.MouseButton; //导入依赖的package包/类
private void onPressed(Node dragged, MouseEvent event) {
    if (event.getButton() == MouseButton.PRIMARY) {
        dragActive = true;
        inertiaOvercome = false;
        nodeXOnPress = dragged.getLayoutX();
        mouseXOnPress = event.getScreenX();

        minWidthBackup = container.getMinWidth();
        prefWidthBackup = container.getPrefWidth();
        maxWidthBackup = container.getMaxWidth();
        container.setMinWidth(container.getWidth());
        container.setPrefWidth(container.getWidth());
        container.setMaxWidth(container.getWidth());

        translates = moveableChildren().collect(Collectors.toMap(Function.identity(), child -> new TranslateAnimation(child, dragged)));
        moveableChildren().forEach(child -> child.setManaged(false));

        // Move dragged node temporarily to front. Reset to original index on mouse release.
        dragged.toFront();
    }
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:22,代码来源:KeyFrameDragAnimator.java

示例7: click

import javafx.scene.input.MouseButton; //导入依赖的package包/类
@Test public void click() {
    Hyperlink button = (Hyperlink) getPrimaryStage().getScene().getRoot().lookup(".hyperlink");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(new Runnable() {
        @Override public void run() {
            RFXButtonBase rfxButtonBase = new RFXButtonBase(button, null, null, lr);
            Point2D sceneXY = button.localToScene(new Point2D(3, 3));
            PickResult pickResult = new PickResult(button, sceneXY.getX(), sceneXY.getY());
            Point2D screenXY = button.localToScreen(new Point2D(3, 3));
            MouseEvent me = new MouseEvent(button, button, MouseEvent.MOUSE_PRESSED, 3, 3, sceneXY.getX(), screenXY.getY(),
                    MouseButton.PRIMARY, 1, false, false, false, false, true, false, false, false, false, false, pickResult);
            rfxButtonBase.mouseButton1Pressed(me);
        }
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording select = recordings.get(0);
    AssertJUnit.assertEquals("click", select.getCall());
    AssertJUnit.assertEquals("", select.getParameters()[0]);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:RFXHyperlinkButtonTest.java

示例8: getText

import javafx.scene.input.MouseButton; //导入依赖的package包/类
@Test public void getText() {
    Button button = (Button) getPrimaryStage().getScene().getRoot().lookup(".button");
    LoggingRecorder lr = new LoggingRecorder();
    List<String> text = new ArrayList<>();
    Platform.runLater(new Runnable() {
        @Override public void run() {
            RFXButtonBase rfxButtonBase = new RFXButtonBase(button, null, null, lr);
            Point2D sceneXY = button.localToScene(new Point2D(3, 3));
            PickResult pickResult = new PickResult(button, sceneXY.getX(), sceneXY.getY());
            Point2D screenXY = button.localToScreen(new Point2D(3, 3));
            MouseEvent me = new MouseEvent(button, button, MouseEvent.MOUSE_PRESSED, 3, 3, sceneXY.getX(), screenXY.getY(),
                    MouseButton.PRIMARY, 1, false, false, false, false, true, false, false, false, false, false, pickResult);
            rfxButtonBase.mouseButton1Pressed(me);
            text.add(rfxButtonBase.getAttribute("text"));
        }
    });
    new Wait("Waiting for button text.") {
        @Override public boolean until() {
            return text.size() > 0;
        }
    };
    AssertJUnit.assertEquals("Color", text.get(0));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:24,代码来源:RFXButtonBaseTest.java

示例9: changeHiddenPower

import javafx.scene.input.MouseButton; //导入依赖的package包/类
public void changeHiddenPower(Event event) {
    if (event instanceof MouseEvent) {
        MouseEvent mouseEvent = (MouseEvent) event;
        MouseButton mouseButton = mouseEvent.getButton();
        if (mouseEvent.isShiftDown() || mouseButton.equals(MouseButton.SECONDARY)) {
            pokemon.setHiddenPower(hiddenPowerCalculator.updateToNext());
        } else if (mouseButton.equals(MouseButton.PRIMARY)) {
            pokemon.setHiddenPower(hiddenPowerCalculator.updateToPrevious());
        } else if (mouseButton.equals(MouseButton.MIDDLE)) {
            pokemon.setHiddenPower(hiddenPowerCalculator.setUnknown());
        }
    } else if (event instanceof ScrollEvent) {
        double delta = ((ScrollEvent) event).getDeltaY();
        if (delta > 0) {
            pokemon.setHiddenPower(hiddenPowerCalculator.updateToNext());
        } else if (delta < 0) {
            pokemon.setHiddenPower(hiddenPowerCalculator.updateToPrevious());
        }
    }
}
 
开发者ID:wartab,项目名称:gen7-iv-calculator,代码行数:21,代码来源:OutputPresenter.java

示例10: createConsole

import javafx.scene.input.MouseButton; //导入依赖的package包/类
private ConsolePane createConsole()
{
	ConsolePane console = new ConsolePane();
	ContextMenu contextMenu = new ContextMenu();
	
	MenuItem clearConsoleItem = new MenuItem("Clear");
	clearConsoleItem.setOnAction(e -> console.clear());
	contextMenu.getItems().add(clearConsoleItem);
	
	console.addEventHandler(ContextMenuEvent.CONTEXT_MENU_REQUESTED, event -> {
		contextMenu.show(console, event.getScreenX(), event.getScreenY());
		event.consume();
	});
	console.setOnMouseClicked(event -> {
		if (event.getButton() == MouseButton.PRIMARY)
			contextMenu.hide();
	});
	
	return console;
}
 
开发者ID:dhawal9035,项目名称:WebPLP,代码行数:21,代码来源:Main.java

示例11: createEntry

import javafx.scene.input.MouseButton; //导入依赖的package包/类
private void createEntry(MouseEvent evt) {
    if (evt.getButton().equals(MouseButton.PRIMARY) && evt.getClickCount() == 2) {
        LoggingDomain.VIEW.fine("create entry mouse event received inside control: " + dateControl.getClass().getSimpleName());

        ZonedDateTime time = ZonedDateTime.now();
        if (dateControl instanceof ZonedDateTimeProvider) {
            ZonedDateTimeProvider provider = (ZonedDateTimeProvider) dateControl;
            time = provider.getZonedDateTimeAt(evt.getX(), evt.getY());
        }

        Optional<Calendar> calendar = dateControl.getCalendarAt(evt.getX(), evt.getY());

        if (time != null) {
            dateControl.createEntryAt(time, calendar.orElse(null));
        }
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:18,代码来源:CreateDeleteHandler.java

示例12: mouseReleased

import javafx.scene.input.MouseButton; //导入依赖的package包/类
private void mouseReleased(MouseEvent evt) {
    if (!evt.getButton().equals(MouseButton.PRIMARY) || dayEntryView == null || dragMode == null || !dragging) {
        return;
    }
    dragging = false;

    Calendar calendar = entry.getCalendar();
    if (calendar.isReadOnly()) {
        return;
    }

    dayEntryView.getProperties().put("dragged", false); //$NON-NLS-1$
    dayEntryView.getProperties().put("dragged-start", false); //$NON-NLS-1$
    dayEntryView.getProperties().put("dragged-end", false); //$NON-NLS-1$

    /*
     * We might run in the sampler application. Then the entry view will not
     * be inside a date control.
     */
    DraggedEntry draggedEntry = dayView.getDraggedEntry();

    if (draggedEntry != null) {
        entry.setInterval(draggedEntry.getInterval());
        dayView.setDraggedEntry(null);
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:27,代码来源:DayViewEditController.java

示例13: by

import javafx.scene.input.MouseButton; //导入依赖的package包/类
/**
 * Create an operation dragging from an absolute position to a relative position
 * from there
 * 
 * @param d
 *            the duration
 * @param fromX
 *            the start x coordinate on screen
 * @param fromY
 *            the start y coordinate on screen
 * @param dx
 *            delta of the x coordinate
 * @param dy
 *            delta of the y coordinate
 * @return the operation
 */
public static Operation by(Duration d, double fromX, double fromY, double dx, double dy) {
	return (r) -> {
		r.mouseMoveTo((int) fromX, (int) fromY);
		r.press(MouseButton.PRIMARY);
		BlockCondition<Void> b = new BlockCondition<>();
		Transition tt = new Transition() {
			{
				setCycleDuration(javafx.util.Duration.millis(d.toMillis()));
			}

			@Override
			protected void interpolate(double frac) {
				r.mouseMoveTo((int) (fromX + dx * frac), (int) (fromY + dy * frac));
			}
		};
		tt.setOnFinished(e -> b.release(null));
		tt.play();
		r.block(b);
		r.release(MouseButton.PRIMARY);
		return r;
	};
}
 
开发者ID:BestSolution-at,项目名称:FX-Test,代码行数:39,代码来源:Drag.java

示例14: onBackgroundDragged

import javafx.scene.input.MouseButton; //导入依赖的package包/类
private void onBackgroundDragged(MouseEvent event) {
    if (event.getButton() == MouseButton.PRIMARY && dragActive) {
        double x = event.getX() - panningComponent.panXProperty().get();
        double y = event.getY() - panningComponent.panYProperty().get();

        double minX = Math.min(x, xAtPress);
        double minY = Math.min(y, yAtPress);
        double maxX = Math.max(x, xAtPress);
        double maxY = Math.max(y, yAtPress);

        root.setVisible(true);
        root.setLayoutX(minX);
        root.setLayoutY(minY);
        root.setWidth(maxX - minX);
        root.setHeight(maxY - minY);
    }
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:18,代码来源:SelectionBoxComponent.java

示例15: makeOnButtonDownListener

import javafx.scene.input.MouseButton; //导入依赖的package包/类
private EventHandler<MouseEvent> makeOnButtonDownListener(){
	return new EventHandler<MouseEvent>() {

		@Override
		public void handle(MouseEvent event) {
			if(event.getButton() == MouseButton.PRIMARY){
				HitInfo i = DnDTextInput.getHitInfo((TextInputControl) event.getSource(), event);
				IndexRange r = textInput.getSelection();
				
				if(DnDTextInput.isInRange(i.getInsertionIndex(), r)){
					currentSelection = r;
				}
				
				inClick = true;
			}
		}
	};
}
 
开发者ID:coalang-soft,项目名称:dragdropfx,代码行数:19,代码来源:TextDragListenerContext.java


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