Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
8236839: System menubar removed when other menubars are created or mo…
…dified
Reviewed-by: kcr, aghaisas
- Loading branch information
|
@@ -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; |
|
|