简体   繁体   English

鼠标拖动时如何在舞台上设置事件?

[英]How to set event on stage while mouse dragging?

I want to fire an event while dragging stage. 我想在拖动舞台时触发一个事件。 I found a lot of examples about undecorated stage dragging which has set event (MouseEvent) on pane but not on stage. 我发现了很多有关未经修饰的舞台拖动的示例,这些示例在窗格中设置了事件(MouseEvent),但未在舞台上设置。 Is there any way through which I can solve this problem? 有什么办法可以解决这个问题?

Does it work just to observe the x and y properties of the stage? 仅仅观察舞台的x和y属性是否起作用?

ie: 即:

final Stage stage ;
// ...

ChangeListener<Number> stageMoveListener = new ChangeListener<Number>() {
    @Override
    public void changed(ObservableValue<? extends Number> ov, Number oldValue, Number new Value) {
        System.out.println("Stage moved to "+stage.getX()+", "+stage.getY());
    }
});
stage.xProperty().addListener(stageMoveListener);
stage.yProperty().addListener(stageMoveListener);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM