Release the click after amount of drag

问题: Is there a way after the user presses the left click and drag something, after some amount of time or condition to release the left click? I don't want to consume the event...

问题:

Is there a way after the user presses the left click and drag something, after some amount of time or condition to release the left click? I don't want to consume the event, also if I disable the node the press is still there and the drag is still going, nor I want to remove the event, because another event is dependent on it. I just want the node to be released from the left click press.


回答1:

For swing, you do it very similar to this, so it shouldn't be too far off for JavaFX

void drag(Point p) {
    MouseEvent leftClick = new LeftClickEvent();//Substitute naming for proper instantiation
    MouseEvent drag = new DragEvent(); //Substitute naming for proper instantiation
    MouseEvent release = new ReleaseEvent(); //Substitute naming for proper instantiation

    swing.processEvent(leftClick);
    swing.processEvent(drag);
    swing.processEvent(release);

}
  • 发表于 2019-03-05 12:33
  • 阅读 ( 186 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除