B4J Question How to prevent a Titledpane's collapse/expand event when clicking a node that's in its graphic area

TelKel81

Active Member
Licensed User
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.
 
Solution
Resolved the issue by also handling MousePressed and MouseReleased events (of the imageview) and consuming them, preventing those events from propagating to the titledpane.

DarkoT

Active Member
Licensed User
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
 
Upvote 0

TelKel81

Active Member
Licensed User
Resolved the issue by also handling MousePressed and MouseReleased events (of the imageview) and consuming them, preventing those events from propagating to the titledpane.
 
Last edited:
Upvote 0
Solution
Top