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


Java MouseEvent.getButton方法代码示例

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


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

示例1: canvasClicked

import javafx.scene.input.MouseEvent; //导入方法依赖的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: changeHiddenPower

import javafx.scene.input.MouseEvent; //导入方法依赖的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

示例3: handle

import javafx.scene.input.MouseEvent; //导入方法依赖的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

示例4: 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

示例5: onMousePressed

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
private void onMousePressed(MouseEvent event) {
    if (event.getButton() == MouseButton.SECONDARY) {
        contentXAtPress = view.getContent().getLayoutX();
        contentYAtPress = view.getContent().getLayoutY();
        screenXAtPress = event.getScreenX();
        screenYAtPress = event.getScreenY();
        setSceneCursor(Cursor.MOVE);
        panningActive = true;
    }
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:11,代码来源:PanningPresenter.java

示例6: recordClick2

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
@Override public void recordClick2(final RFXComponent r, MouseEvent e, boolean withCellInfo) {
    final JSONObject event = new JSONObject();
    event.put("type", "click");
    int button = e.getButton() == MouseButton.PRIMARY ? java.awt.event.MouseEvent.BUTTON1 : java.awt.event.MouseEvent.BUTTON3;
    event.put("button", button);
    event.put("clickCount", e.getClickCount());
    event.put("modifiersEx", buildModifiersText(e));
    double x = e.getX();
    double y = e.getY();
    Node source = (Node) e.getSource();
    Node target = r.getComponent();
    Point2D sts = source.localToScreen(new Point2D(0, 0));
    Point2D tts = target.localToScreen(new Point2D(0, 0));
    x = e.getX() - tts.getX() + sts.getX();
    y = e.getY() - tts.getY() + sts.getY();
    event.put("x", x);
    event.put("y", y);
    if (withCellInfo) {
        event.put("cellinfo", r.getCellInfo());
    }
    final JSONObject o = new JSONObject();
    o.put("event", event);
    fill(r, o);
    if (e.getClickCount() == 1) {
        clickTimer = new Timer();
        clickTimer.schedule(new TimerTask() {
            @Override public void run() {
                sendRecordMessage(o);
            }
        }, timerinterval.intValue());
    } else if (e.getClickCount() == 2) {
        if (clickTimer != null) {
            clickTimer.cancel();
            clickTimer = null;
        }
        sendRecordMessage(o);
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:39,代码来源:WSRecorder.java

示例7: recordRawMouseEvent

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
@Override public void recordRawMouseEvent(final RFXComponent r, MouseEvent e) {
    final JSONObject event = new JSONObject();
    event.put("type", "click_raw");
    int button = e.getButton() == MouseButton.PRIMARY ? java.awt.event.MouseEvent.BUTTON1 : java.awt.event.MouseEvent.BUTTON3;
    event.put("button", button);
    event.put("clickCount", e.getClickCount());
    event.put("modifiersEx", buildModifiersText(e));
    Node source = (Node) e.getSource();
    Node target = r.getComponent();
    Point2D sts = source.localToScene(new Point2D(e.getX(), e.getY()));
    Point2D tts = target.sceneToLocal(sts);
    event.put("x", tts.getX());
    event.put("y", tts.getY());
    final JSONObject o = new JSONObject();
    o.put("event", event);
    fill(r, o);
    if (e.getClickCount() == 1) {
        clickTimer = new Timer();
        clickTimer.schedule(new TimerTask() {
            @Override public void run() {
                sendRecordMessage(o);
            }
        }, timerinterval.intValue());
    } else if (e.getClickCount() == 2) {
        if (clickTimer != null) {
            clickTimer.cancel();
            clickTimer = null;
        }
        sendRecordMessage(o);
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:32,代码来源:WSRecorder.java

示例8: onBackgroundPressed

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
private void onBackgroundPressed(MouseEvent event) {
    if (event.getButton() == MouseButton.PRIMARY && !playerModel.isPlayMode()) {
        xAtPress = event.getX() - panningComponent.panXProperty().get();
        yAtPress = event.getY() - panningComponent.panYProperty().get();
        dragActive = true;
    }
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:8,代码来源:SelectionBoxComponent.java

示例9: handleMouseClick

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
/**
 * Handles mouse click actions for the scene
 *
 * @param e
 */
private void handleMouseClick (MouseEvent e) {
    if (e.getButton() == MouseButton.PRIMARY && e.getClickCount() == DOUBLE_CLICK) {
        myController.uploadNewBackground();
        myRenderer.updateNewTiles();
        updateBitMap();
        render();
    }
}
 
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:14,代码来源:SceneCreator.java

示例10: requestMoney

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
@FXML
protected void requestMoney(MouseEvent event) {
    if (event.getButton() == MouseButton.SECONDARY || (event.getButton() == MouseButton.PRIMARY && event.isMetaDown())) {
        // User right clicked or the Mac equivalent. Show the context menu.
        addressMenu.show(addressLabel, event.getScreenX(), event.getScreenY());
    } else {
        // User left clicked.
        try {
            Desktop.getDesktop().browse(URI.create(uri()));
        } catch (IOException e) {
            GuiUtils.informationalAlert("Opening wallet app failed", "Perhaps you don't have one installed?");
        }
    }
}
 
开发者ID:creativechain,项目名称:creacoinj,代码行数:15,代码来源:ClickableBitcoinAddress.java

示例11: onBackgroundReleased

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
private void onBackgroundReleased(MouseEvent event) {
    if (event.getButton() == MouseButton.PRIMARY) {
        root.setVisible(false);
        dragActive = false;
        if (!event.isStillSincePress()) {
            selectInBounds(root.getBoundsInParent());
        }
        root.setWidth(0);
        root.setHeight(0);
    }
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:12,代码来源:SelectionBoxComponent.java

示例12: makeOnButtonUpListener

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
private EventHandler<MouseEvent> makeOnButtonUpListener(){
	return new EventHandler<MouseEvent>() {
		@Override
		public void handle(MouseEvent event) {
			if(event.getButton() == MouseButton.PRIMARY && inClick){
				inClick = false;
				currentSelection = null;
			}
		}
	};
}
 
开发者ID:coalang-soft,项目名称:dragdropfx,代码行数:12,代码来源:TextDragListenerContext.java

示例13: onDragged

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
private void onDragged(Node dragged, MouseEvent event) {
    if (!inertiaOvercome) {
        inertiaOvercome = Math.abs(event.getScreenX() - mouseXOnPress) > DRAG_INERTIA;
    }
    if (event.getButton() == MouseButton.PRIMARY && dragActive && inertiaOvercome) {
        dragged.setLayoutX(clamp(nodeXOnPress + event.getScreenX() - mouseXOnPress, dragged));
        moveableChildren().filter(child -> child != dragged).forEach(child -> updatePosition(child, dragged));
    }
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:10,代码来源:KeyFrameDragAnimator.java

示例14: onReleased

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
private void onReleased(MouseEvent event) {
    if (event.getButton() == MouseButton.PRIMARY) {
        dragActive = false;
        if (onResizeDone != null) {
            onResizeDone.run();
        }
        event.consume();
    }
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:10,代码来源:ResizeBehavior.java

示例15: notifyClickEvent

import javafx.scene.input.MouseEvent; //导入方法依赖的package包/类
/**
 * Use this method to process a click event and send a special GUI event by the means of the message system.
 * @param event MouseEvent. A click event
 */
void notifyClickEvent(MouseEvent event) {
    if (!event.isStillSincePress()) {
        return;
    }

    Map<String, Object> m = new HashMap<>();
    m.put("screenX", event.getScreenX());
    m.put("screenY", event.getScreenY());
    m.put("nodeX", event.getScreenX() - sender.getLayoutX());
    m.put("nodeY", event.getScreenY() - sender.getLayoutY());
    m.put("nodeWidth", sender.getLayoutBounds().getWidth());
    m.put("nodeHeight", sender.getLayoutBounds().getHeight());

    StringBuilder eventMessage = new StringBuilder("gui-events:").append(senderName).append("-");
    if (event.getButton() == MouseButton.PRIMARY) {
        if (event.getClickCount() == 2) {
            eventMessage.append("double");
        } else {
            eventMessage.append("left");
        }
    } else if (event.getButton() == MouseButton.SECONDARY) {
        eventMessage.append("right");
    } else if (event.getButton() == MouseButton.MIDDLE) {
        eventMessage.append("middle");
    } else {
        return;
    }
    eventMessage.append("-click");

    Main.getInstance().getPluginProxy().sendMessage(eventMessage.toString(), m);
}
 
开发者ID:DeskChan,项目名称:DeskChan,代码行数:36,代码来源:MouseEventNotificator.java


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