gpt4 book ai didi

JavaFX setOnScrollStarted 和 setOnScrollFinished 不工作

转载 作者:行者123 更新时间:2023-11-30 08:01:04 25 4
gpt4 key购买 nike

我想在 javaFX 中实现 onScrollStartedonScrollFinished 但它们没有工作,尽管 setOnScroll 正在工作.示例代码:

    //One Way
node.setOnScrollStarted(s -> {
System.out.println("ScrollFinished..");
node.setCursor(Cursor.E_RESIZE);
});

node.setOnScrollFinished(s -> {
System.out.println("ScrollStarted...");
node.setCursor(Cursor.DEFAULT);
});

//Other Way
node.addEventFilter(ScrollEvent.SCROLL_STARTED, (x) -> {
System.out.println("ScrollStarted...");
node.setCursor(Cursor.DEFAULT);
});

node.addEventFilter(ScrollEvent.SCROLL_FINISHED, (x) -> {
System.out.println("ScrollFinished..");
node.setCursor(Cursor.E_RESIZE);
});

以上均无效。其中节点是一个 textField。我做错了什么?

最佳答案

参见 ScrollEvent :

When the scrolling is produced by a touch gesture (such as dragging a finger over a touch screen), it is surrounded by the SCROLL_STARTED and SCROLL_FINISHED events. ... When the scrolling is caused by a mouse wheel rotation, only a one-time SCROLL event is delivered, without the started/finished surroundings

如果您使用鼠标滚轮,您将不会收到这些事件。

关于JavaFX setOnScrollStarted 和 setOnScrollFinished 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38016841/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com