How do I detect/handle a right click in JavaFX?
+1
A:
Here's one way:
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.shape.Rectangle;
import javafx.scene.paint.Color;
import javafx.scene.input.*;
var r = Rectangle {
x: 50, y: 50
width: 120, height: 120
fill: Color.RED
onMouseClicked: function(e:MouseEvent):Void {
if (e.button == MouseButton.SECONDARY) {
println("Right button clicked");
}
}
}
Stage {
title : "ClickTest"
scene: Scene {
width: 200
height: 200
content: [ r ]
}
}
Matthew Hegarty
2009-10-05 16:03:07
Brilliant! Thats perfect. I couldn't find a thing about it anywhere. Thanks a bunch!
Mike Williamson
2009-10-06 19:36:07
A:
how can you combine the right click function to a menu bar or pop up box like right cliking it and pop upbox will appear
george
2010-09-24 15:11:06