简体   繁体   English

JavaFX 鼠标事件

[英]JavaFX mouse event

I am using a JavaFX with Java 8 to make a copy of simple 2d Flash Player-game.我正在使用 JavaFX 和 Java 8 来制作简单的 2d Flash 玩家游戏的副本。 I noticed that click event is called when you leave mouse button not when you are pressing it.我注意到当您离开鼠标按钮而不是按下它时会调用单击事件。 Is there a way to fix this?有没有办法来解决这个问题? Thanks.谢谢。 Windows 10 x64 Windows 10 x64

No, you can only fix things which are broken but this is by design.不,您只能修复损坏的东西,但这是设计使然。 How shall the system know that you have clicked on something before you release the mouse button?在您松开鼠标按钮之前,系统如何知道您点击了某物? The first mouse press could also be the start of a drag.第一次鼠标按下也可能是拖动的开始。 Look at the documentation: https://docs.oracle.com/javase/8/javafx/api/javafx/scene/input/MouseEvent.html#MOUSE_CLICKED Depending on your use-case you might use the mouse pressed event instead.查看文档: https://docs.oracle.com/javase/8/javafx/api/javafx/scene/input/MouseEvent.html#MOUSE_CLICKED根据您的用例,您可以改用鼠标按下事件。 https://docs.oracle.com/javase/8/javafx/api/javafx/scene/input/MouseEvent.html#MOUSE_PRESSED https://docs.oracle.com/javase/8/javafx/api/javafx/scene/input/MouseEvent.html#MOUSE_PRESSED

Thanks to @mipa for answering my question, Yes.感谢@mipa 回答我的问题,是的。 i just needed mouse pressed event instead of mouse clicked event我只需要鼠标按下事件而不是鼠标点击事件

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

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