-
-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mnemonics in menus are always displayed #43
Comments
Mnemonic hiding was only implemented for labels, buttons and tabs. However, this is now implemented in master branch. |
The fix works. Minor details with regards to the Alt-key behavior (at least on Windows):
Here is a test case: public static void main(String[] args) throws Exception {
// UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
UIManager.setLookAndFeel(new FlatLightLaf());
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar menuBar = new JMenuBar();
JMenu menu1 = new JMenu("Menu 1");
menu1.setMnemonic('m');
JMenuItem subMenu1_1 = new JMenuItem("Sub Menu 1.1");
subMenu1_1.setMnemonic('s');
menu1.add(subMenu1_1);
menuBar.add(menu1);
frame.setJMenuBar(menuBar);
// frame.setContentPane(new JScrollPane(new JTextArea()));
frame.setSize(400, 300);
frame.setVisible(true);
} You can easily swap with the native L&F to see the difference (first comment), and you can easily add a focusable component (second comment). |
…; ignore invisible components (issue #43)
Ok, now how I can disable this feature if I don't like it? |
No problem. See "Show Mnemonics" section here: https://www.formdev.com/flatlaf/customizing/#show_mnemonics |
I checked the latest changes and here are the current issues I found:
|
Chrriis wrote:
No, commit 870d039 only hides the mnemonic when deactivating window (e.g. Alt+Tab to other window). This addresses the first point in #43 (comment) Commit e3ed47b is responsible for showing mnemonics as soon as menu bar is active or a popup menu is visible. What's wrong with this? |
Well, mnemonics are noisy indications, so the original feature got tweaked to only reveal them when you press Alt. Activating a menu and having the UI blink everywhere with the mnemonics suddenly appearing is very odd. |
As an additional comment, mnemonics are useful for people who want to use their keyboard to quickly jump. Basic users would simply use their mouse and they absolutely do not care about mnemonics and the graphical noise they add. Showing mnemonics on mouse actions is very odd. |
Ok, thanks for your feedback. Sounds reasonable. I'll change it... |
Don't stop 😉 This brings FlatLaf forward. Details matter. Activating menu with Alt key (on Windows) is now implemented in master branch. |
Much better indeed. |
…lt key did not always work (issue #43)
Good catch 👍 |
good job guys. |
With the system L&F (Windows 10), mnemonics are not displayed in menus unless I press the Alt key. With FlatLaf, mnemonics are always displayed.
I see that the FlatLaf code triggers repainting on the hierarchy when Alt is pressed or released, but this has no visual impact.
Unless I am mistaken, FlatMenuUI extends BasicMenuUI, and BasicMenuUI always paints the mnemonic. WindowsMenuItemUI (for system L&F) also extends BasicMenuItemUI but overrides paintText to have the mnemonic show/hide logic.
Please, let me know if I did something wrong 🙂
The text was updated successfully, but these errors were encountered: