Skip to content

Commit 369b23a

Browse files
committed
Refactored function to get status of menus in MacOSX
1 parent 59a57a9 commit 369b23a

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

app/src/processing/app/Base.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ public boolean handleQuit() {
971971
// Save out the current prefs state
972972
PreferencesData.save();
973973

974-
if (!OSUtils.isMacOS() || System.getProperty("apple.laf.useScreenMenuBar") == "false") {
974+
if (!OSUtils.hasMacOSStyleMenus()) {
975975
// If this was fired from the menu or an AppleEvent (the Finder),
976976
// then Mac OS X will send the terminate signal itself.
977977
System.exit(0);

app/src/processing/app/Editor.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ public void actionPerformed(ActionEvent e) {
619619
fileMenu.add(item);
620620

621621
// macosx already has its own preferences and quit menu
622-
if (!OSUtils.isMacOS() || System.getProperty("apple.laf.useScreenMenuBar") == "false") {
622+
if (!OSUtils.hasMacOSStyleMenus()) {
623623
fileMenu.addSeparator();
624624

625625
item = newJMenuItem(tr("Preferences"), ',');
@@ -1252,7 +1252,7 @@ public void actionPerformed(ActionEvent e) {
12521252
menu.add(item);
12531253

12541254
// macosx already has its own about menu
1255-
if (!OSUtils.isMacOS() || System.getProperty("apple.laf.useScreenMenuBar") == "false") {
1255+
if (!OSUtils.hasMacOSStyleMenus()) {
12561256
menu.addSeparator();
12571257
item = new JMenuItem(tr("About Arduino"));
12581258
item.addActionListener(new ActionListener() {
@@ -1812,7 +1812,7 @@ protected boolean checkModified() {
18121812
String prompt = I18n.format(tr("Save changes to \"{0}\"? "),
18131813
sketch.getName());
18141814

1815-
if (!OSUtils.isMacOS() || System.getProperty("apple.laf.useScreenMenuBar") == "false") {
1815+
if (!OSUtils.hasMacOSStyleMenus()) {
18161816
int result =
18171817
JOptionPane.showConfirmDialog(this, prompt, tr("Close"),
18181818
JOptionPane.YES_NO_CANCEL_OPTION,

arduino-core/src/processing/app/helpers/OSUtils.java

+3
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,7 @@ static public boolean isMacOS() {
2626
return System.getProperty("os.name").contains("Mac");
2727
}
2828

29+
static public boolean hasMacOSStyleMenus() {
30+
return OSUtils.isMacOS() && System.getProperty("apple.laf.useScreenMenuBar").equals("true");
31+
}
2932
}

0 commit comments

Comments
 (0)