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

Menubar not showing when using CustomMenuItem #18

Open
vewert opened this issue Dec 20, 2021 · 5 comments
Open

Menubar not showing when using CustomMenuItem #18

vewert opened this issue Dec 20, 2021 · 5 comments

Comments

@vewert
Copy link

vewert commented Dec 20, 2021

When running my application on macOS, I noticed the Application menubar was not showing any more, and I saw the following in the console:
Warning: MenuBar ignored property useSystemMenuBar because menus contain CustomMenuItem

I recently added a submenu that uses CustomMenuItem. When I removed that, the menubar worked again.

I did some digging, and it looks like the warning message comes from the MenuBarSkin class:

private boolean menusContainCustomMenuItem() {
  for (Menu menu : getSkinnable().getMenus()) {
    if (menuContainsCustomMenuItem(menu)) {
      System.err.println("Warning: MenuBar ignored property useSystemMenuBar because menus contain CustomMenuItem");
      return true;
    }
  }
  return false;
}

On Windows (where I am not using NSMenuFX), using CustomMenuItem works fine. Is there some reason why CustomMenuItem doesn't work with NSMenuFX?

Thanks for your help.

@0x4a616e
Copy link
Owner

Hi! I think the reason is that custom menus are just not supported in combination with system menu bars https://github.com/openjdk/jfx/blob/c705bd493931d88650542be5466d6add359f45b9/modules/javafx.controls/src/main/java/javafx/scene/control/skin/MenuBarSkin.java#L881

On Windows, you probably don't use system menu bars (as AFAIK Windows doesn't support them at all), which is why it is working there. So I guess that this is less a NSMenuFX issue than a general JavaFX problem. NSMenuFX uses the system menu property of JavaFX to put menus into the macOS system menu bar.

@vewert
Copy link
Author

vewert commented Dec 24, 2021

Hmmm, that is unfortunate. I was using CustomMenuItems so I could add tooltips to some of my menu items. Other than not using CustomMenuItems, do you know of any work-arounds for this?

@0x4a616e
Copy link
Owner

0x4a616e commented Dec 27, 2021

Hmm, apparently macOS menu items do support tooltips: https://developer.apple.com/documentation/appkit/nsmenuitem/1514848-tooltip?language=objc
Unfortunately, I cannot think of any way to make this work with JavaFX. The only thing I can think of right now is to add some helper class that lets you add tooltips to menu items created by NSMenuFX.

@vewert
Copy link
Author

vewert commented Dec 27, 2021

Thanks for looking into this. For now I will switch to use regular MenuItem, and then see if can figure out a way to get tooltips to work.

@Oliver-Loeffler
Copy link

Windows does not seem to support tool tips either in its standard menus. May QT does this but not necessarily the windows standard framework. Haven't seen any macOS apps with tooltips in menus. If macOS supports this, then this would require an enhancement request for OpenJFX.

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

No branches or pull requests

3 participants