This looks to me like a good solution, with a rather small probability of 
breaking the existing application code.

-andy



From: openjfx-dev <openjfx-dev-r...@openjdk.org> on behalf of Marius Hanl 
<mariush...@web.de>
Date: Monday, May 15, 2023 at 15:05
To: openjfx-dev <openjfx-dev@openjdk.org>
Subject: Customizable Table Button Menu
In https://github.com/openjdk/jfx/pull/1135 I implemented a way to override the 
behaviour when the table menu button is clicked.

Current behaviour
The table menu button is visible when setTableMenuButtonVisible(true) is called.
When clicked, a ContextMenu is shown with all available columns of the table 
shown as MenuItem.
A user can then click on a MenuItem to make the corresponding column 
(in)visible and the ContextMenu closes afterwards.

Problems
This comes with some limitations as described here 
https://bugs.openjdk.org/browse/JDK-8091419, here 
https://bugs.openjdk.org/browse/JDK-8091153 and here 
https://bugs.openjdk.org/browse/JDK-8092148.
In short:
- It is not always desired that the ContextMenu closes after the user clicked 
on a MenuItem. This is a limitation of the ContextMenu
- The menu can not be invoked programmatically
- The menu can not overridden in any way

Solution
To address these issues, the PR mentioned above adds a new protected method 
showColumnMenu(MouseEvent) which is called when the table menu button is 
clicked.
Since this new method is protected, it can be overidden by developers. If not 
overridden, the known default ContextMenu is created and shown, as described 
above.

This gives every developer the ability to fully customize the behaviour when 
the table menu button is clicked.
A developer can implement their own Menu if the behaviour of the ContextMenu is 
not desired.
The method can now also be invoked programmatically.

Feel free to give Feedback and/or checkout the PR.

-- Marius

Reply via email to