B4J Question Consuming mouse events

alwaysbusy

Expert
Licensed User
Longtime User
Is there a possibility to consume mouse event in B4J?

I have a ScrollPane with a smaller Canvas in it. The scrollPane uses the MouseClicked event, the canvas uses the MousePressed/MouseReleased. Is it somehow possible to consume the event when Canvas_MouseReleased is raised so the Scroll_MouseClicked does not happen anymore?

I tried setting EventData.Consume in both MousePressed and MouseReleased, but it still goes to MouseClicked of the parent.
 
Last edited:

Daestrum

Expert
Licensed User
Longtime User
Just a suggestion, not tried it, but you could probably disable the mouseclicked handler for the scrollpane when the mouse enters the canvas, and restore it when the mouse exits the canvas. You would need to use javaobject or a small bit of java code to get the getOnMouseClicked handler and then restore it with setOnMouseClicked.

Pseudo
canvas.setOnMouseEntered(...
savedHandler = scrollpane.getOnMouseClicked()
...
)
canvas.setOnMouseExited(...
scrollpane.setOnMouseClicked(savedHandler)
...
}
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…