本文整理汇总了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);
}
}
示例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());
}
}
}
示例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());
}
}
}
示例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();
}
}
示例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;
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
}
示例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();
}
}
示例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?");
}
}
}
示例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);
}
}
示例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;
}
}
};
}
示例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));
}
}
示例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();
}
}
示例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);
}