Skip to content
Permalink
Browse files

8236839: System menubar removed when other menubars are created or mo…

…dified

Reviewed-by: kcr, aghaisas
  • Loading branch information
jkaving authored and kevinrushforth committed Feb 7, 2020
1 parent 21d3b7e commit a74137a1191605f878a25e5f2717b0358fd9368a
@@ -866,7 +866,8 @@ private void rebuildUI() {
setSystemMenu(stage);
}
} else {
if (curMBSkin != null && curMBSkin.getSkinnable() != null &&
if (getSkinnable().isUseSystemMenuBar() &&
curMBSkin != null && curMBSkin.getSkinnable() != null &&
curMBSkin.getSkinnable().isUseSystemMenuBar()) {
curMBSkin.getSkinnable().setUseSystemMenuBar(false);
}
@@ -26,6 +26,7 @@
package test.javafx.scene.control.skin;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import com.sun.javafx.menu.MenuBase;
import com.sun.javafx.stage.WindowHelper;
@@ -37,6 +38,7 @@
import javafx.scene.Scene;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.stage.Stage;

import java.util.List;
@@ -163,6 +165,35 @@
}
}

@Test public void testModifyingNonSystemMenuBar() {
if (tk.getSystemMenu().isSupported()) {
// Set system menubar to true
menubar.setUseSystemMenuBar(true);

// Create a secondary menubar that is not
// a system menubar
MenuBar secondaryMenuBar = new MenuBar(
new Menu("Menu 1", null, new MenuItem("Item 1")),
new Menu("Menu 2", null, new MenuItem("Item 2")));
secondaryMenuBar.setSkin(new MenuBarSkin(secondaryMenuBar));

// Add the secondary menubar to the scene
((Group)scene.getRoot()).getChildren().add(secondaryMenuBar);

// Verify that the menubar is the system menubar
assertTrue(menubar.isUseSystemMenuBar());

// Remove a menu from the secondary menubar
// to trigger a rebuild of its UI and a call
// to the sceneProperty listener
secondaryMenuBar.getMenus().remove(1);

// Verify that this has not affected whether the
// original menubar is the system menubar
assertTrue(menubar.isUseSystemMenuBar());
}
}

public static final class MenuBarSkinMock extends MenuBarSkin {
boolean propertyChanged = false;
int propertyChangeCount = 0;

0 comments on commit a74137a

Please sign in to comment.
You can’t perform that action at this time.