NSMenuFX icon indicating copy to clipboard operation
NSMenuFX copied to clipboard

New Stage puts App menu on it

Open EasyG0ing1 opened this issue 2 years ago • 2 comments

Just started trying to implement this library into an app of mine, and I got it properly showing the menu at the top of the screen in MacOs, but when I create new scenes (with new stages) they get a copy of the menu placed on them as you can see in the attached screen shot.

How do I prevent this from happening?

Screen Shot 2022-09-25 at 11 55 41 AM

EasyG0ing1 avatar Sep 25 '22 18:09 EasyG0ing1

For each MenuBar, it might be required to set the property useSystemMenuBar to true. This can be achieved using recent versions of Scene Builder or manually in the FXML.

Do the new Scenes and Stages also have their own menus?

Bildschirmfoto 2022-10-22 um 20 18 27

The FXML looks as follows:

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <MenuBar prefHeight="11.0" prefWidth="140.0" useSystemMenuBar="true">
        <menus>
          <Menu mnemonicParsing="false" text="File">
            <items>
              <MenuItem mnemonicParsing="false" text="Close" />
            </items>
          </Menu>
          <Menu mnemonicParsing="false" text="Edit">
            <items>
              <MenuItem mnemonicParsing="false" text="Delete" />
            </items>
          </Menu>
          <Menu mnemonicParsing="false" text="Help">
            <items>
              <MenuItem mnemonicParsing="false" text="About" />
            </items>
          </Menu>
        </menus>
      </MenuBar>
   </children>
</AnchorPane>

In Java code its:

MenuBar menuBar = new MenuBar();
menuBar.useSystemMenuBarProperty().setValue(true);

Oliver-Loeffler avatar Oct 22 '22 18:10 Oliver-Loeffler

@Oliver-Loeffler Sorry I didn't catch that you commented on here till today.

To answer your question, NO, those other windows do not have any menu on them at all, and I don't use FXML ... I stopped using it years ago. So for example, the screenshot I showed you normally looks like this:

Screenshot 2023-01-26 at 11 55 26 AM

But when I use your library, it throws a menu on every Scene for some reason. I only have one window with a menu and everything else is dialogue style only built manually with standard Scenes and Stages.

EasyG0ing1 avatar Jan 26 '23 19:01 EasyG0ing1