I have an Accordian with multiple TitledPanes. When a TitledPane is expanded, there are "dead areas" on the pane that do not have sub-components (e.g., buttons, text, etc.).
Right now, when I check MouseEvent.getSource(), it returns an instance of TitledPane for all areas. Is there a way to specifically constrain/check for a mouse-click on the "title" section of the TitledPane?
I don't think there is a public API to detect mouse click on title region, however it is possible to do that this way:
But this method is highly discouraged as it relies on some internal implementation detail that may be subject to change.
May be it's better to think more about what you actually need. Maybe your actual requirement can be fulfilled by uisng
TitledPane
's public API methods and properties.For insatnce
expandedProperty()
's value gets changed every time mouse click occurs on title region (ifisCollapsible()
is set totrue
).