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

8236839: System menubar removed when other menubars are created or modified #86

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -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;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.