I added an imageview to the graphic area (via setGraphic method) of a Titledpane.
When I click the imageview, the MouseClick event triggers for both the imageview and the titledpane (so it expands/collapses). I want to avoid this behavior when clicking on the imageview.
I do use event.consume in the imageview's mouseclick event sub.
Resolved the issue by also handling MousePressed and MouseReleased events (of the imageview) and consuming them, preventing those events from propagating to the titledpane.
In case that you received more triggers in object, you can filter MouseClick event for specified object...
Like this:
Example code:
' comments
' TpMain = tab panel (=tabpane)
' example filters events which is not clicket on TabHeader
Sub tpMain_Filter (EventData As Event)
Dim ContextMenuEvent As JavaObject = EventData
Dim Target As JavaObject = ContextMenuEvent.RunMethod("getTarget", Null)
If Target Is Node Then
Dim n As Node = Target
Do While n.IsInitialized
If GetType(n) = "javafx.scene.control.skin.TabPaneSkin$TabHeaderSkin" Then Return
n = n.Parent
Loop
End If
EventData.Consume
End Sub
Resolved the issue by also handling MousePressed and MouseReleased events (of the imageview) and consuming them, preventing those events from propagating to the titledpane.