Skip to content
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

Menus do not react when mouse hovers, unlike all other clickable components #49

Closed
Chrriis opened this issue Jan 20, 2020 · 9 comments
Closed
Labels
enhancement New feature or request

Comments

@Chrriis
Copy link
Contributor

Chrriis commented Jan 20, 2020

Under FlatLaf, components change style on mouse hover: buttons get a different border, tabs get a gray background, etc. It makes the application feel "alive" too.
Menus do not react and feel "dead". I think they should get a gray background, like tabs.

I also wonder if an "tab" style would be appropriate, like toggle buttons.

Simple test case of a menu bar:

	public static void main(String[] args) throws Exception {
		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);
		JMenu menu2 = new JMenu("Menu 2");
		menu2.setMnemonic('n');
		JMenuItem subMenu2_1 = new JMenuItem("Sub Menu 2.1");
		subMenu2_1.setMnemonic('u');
		menu2.add(subMenu2_1);
		menuBar.add(menu2);
		frame.setJMenuBar(menuBar);
		frame.setContentPane(new JScrollPane(new JTextArea()));
		frame.setSize(400, 300);
		frame.setVisible(true);
	}
@DevCharly DevCharly added the enhancement New feature or request label Jan 20, 2020
@DevCharly
Copy link
Collaborator

Yes, that's missing.

Now implemented in master branch 😃

@Chrriis
Copy link
Contributor Author

Chrriis commented Jan 21, 2020

Yes, much better! Thanks a lot!

What do you think of the suggestion of supporting a "tab" type for menus, similar to toggle buttons? Is it valid? Should I open a separate issue?

@DevCharly
Copy link
Collaborator

Something like this?
image

I think this may be confusing because the "tab" style is used to switch content.

@DevCharly
Copy link
Collaborator

hover in menu bar is implemented in 0.26

@Chrriis
Copy link
Contributor Author

Chrriis commented Jan 22, 2020

I think this may be confusing because the "tab" style is used to switch content.

Well, you are right if the hover behaved like a tab. Rather, I had the following in mind:
MenusWithTabStyle

So:

  • hover would be like now.
  • click shows selection like a tab. In effect, it is selected.

@DevCharly
Copy link
Collaborator

But then selected menu looks like a tab...
What should then selected menu items look like?

@Chrriis
Copy link
Contributor Author

Chrriis commented Jan 22, 2020

But then selected menu looks like a tab...

True, but only when the sub-menu is showing: you know what got activated. Currently, selection behaves like a tree or a list (is that better?):
MenusWithTabStyle2Original

My initial reaction was that with a modern L&F like FlatLaf, something better could be found in this area than a Windows 95 kind of selection 🙂
The other candidate I could think of is the underline selection indicator. I am sure I saw it on some websites for some menus but I cannot get my hands on one of them... Nevertheless, the semantics are not far off: selection reveals a component.

This is just brainstorming, and your question is legitimate: how would sub-menus behave? Well, they could remain the same, or they could have a similar style. Here is an attempt:
MenusWithTabStyle2Possibility

Hope this helps!

@Chrriis
Copy link
Contributor Author

Chrriis commented Jan 23, 2020

I found some websites with underline menus. Here is one example: https://www.zalando.fr
You just hover to show the popup (no click), but it is definitely not a tab.

@DevCharly
Copy link
Collaborator

@Chrriis while working on new menu item layout to fix #3, I've also implemented your idea.
Looks nice 👍

image

Can be enabled with:

UIManager.put( "MenuItem.selectionType", "underline" );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants