mirror of
https://gitlab.com/kauron/jstudy
synced 2024-11-13 07:33:44 +01:00
Main: adapted menu to macOS style.
This commit is contained in:
parent
8a279ae1cb
commit
ca23f61c72
2 changed files with 23 additions and 1 deletions
|
@ -16,6 +16,8 @@ import javafx.fxml.FXML;
|
|||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.control.Menu;
|
||||
import javafx.scene.control.MenuBar;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.image.Image;
|
||||
|
@ -54,6 +56,9 @@ public class Controller implements Initializable {
|
|||
@FXML
|
||||
private MenuItem menuCloseTab, menuSave, menuUndo, menuRedo;
|
||||
|
||||
@FXML
|
||||
private MenuBar menuBar;
|
||||
|
||||
private final BooleanProperty tabIsTable = new SimpleBooleanProperty(false);
|
||||
private final Map<Tab, Initializable> tabMap = new HashMap<>();
|
||||
private String updateURL, updateFileName;
|
||||
|
@ -96,9 +101,26 @@ public class Controller implements Initializable {
|
|||
}
|
||||
})
|
||||
);
|
||||
// Do not show icons in the menu items of the main menu in macOS.
|
||||
Platform.runLater(() -> {
|
||||
if (System.getProperty("os.name").toLowerCase().startsWith("mac os x"))
|
||||
for (Menu m : menuBar.getMenus())
|
||||
removeIcon(m);
|
||||
});
|
||||
new Thread(this::checkUpdate).start();
|
||||
}
|
||||
|
||||
private void removeIcon(Menu menu) {
|
||||
menu.setGraphic(null);
|
||||
for (MenuItem item : menu.getItems()) {
|
||||
if (item instanceof Menu) {
|
||||
removeIcon((Menu) item);
|
||||
} else {
|
||||
item.setGraphic(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isTableTab(Tab tab) {
|
||||
return tabMap.containsKey(tab) && tabMap.get(tab) instanceof TableController;
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
</TabPane>
|
||||
</center>
|
||||
<top>
|
||||
<MenuBar>
|
||||
<MenuBar fx:id="menuBar" useSystemMenuBar="true">
|
||||
<menus>
|
||||
<Menu text="_File">
|
||||
<items>
|
||||
|
|
Loading…
Reference in a new issue