2009-10-04 38 views

Respuesta

15

Aquí hay una manera:

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 ] 
    } 
} 
+0

Brilliant! Eso es perfecto. No pude encontrar nada sobre eso en ninguna parte. ¡Gracias un montón! – mikewilliamson

+0

@mikewilliamson ¿Puedo cambiar el nombre del botón para este [botón] (https://paste.ubuntu.com/25684310/) cuando se presiona el botón derecho del mouse? – alhelal

Cuestiones relacionadas