2009-10-04 170 views

回答

15

這裏有一種方法:

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

輝煌!那很完美。我在任何地方都找不到它。謝謝一堆! – mikewilliamson 2009-10-06 19:36:07

+0

@mikewilliamson當鼠標右鍵單擊時,是否可以更改此[按鈕](https://paste.ubuntu.com/25684310/)的按鈕名稱? – alhelal 2017-10-06 06:21:27