deal with menu quirks (bug #1260)

This commit is contained in:
benfry
2009-06-07 22:58:00 +00:00
parent 55501fe182
commit eaadcaec11
2 changed files with 34 additions and 25 deletions

View File

@@ -7,9 +7,8 @@
Copyright (c) 2001-04 Massachusetts Institute of Technology
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -971,9 +970,16 @@ public class Base {
protected void rebuildSketchbookMenu(JMenu menu) {
//System.out.println("rebuilding sketchbook menu");
//new Exception().printStackTrace();
boolean nativeButBroken = Base.isMacOS() ?
Preferences.getBoolean("apple.laf.useScreenMenuBar") : false;
try {
menu.removeAll();
addSketches(menu, getSketchbookFolder(), false);
if (nativeButBroken) { // osx workaround
menu.setEnabled(false);
} else {
menu.removeAll();
addSketches(menu, getSketchbookFolder(), false);
}
} catch (IOException e) {
e.printStackTrace();
}
@@ -1012,10 +1018,16 @@ public class Base {
public void rebuildExamplesMenu(JMenu menu) {
//System.out.println("rebuilding examples menu");
boolean nativeButBroken = Base.isMacOS() ?
Preferences.getBoolean("apple.laf.useScreenMenuBar") : false;
try {
menu.removeAll();
addSketches(menu, examplesFolder, false);
if (nativeButBroken) { // osx workaround
menu.setEnabled(false);
} else {
menu.removeAll();
addSketches(menu, examplesFolder, false);
}
} catch (IOException e) {
e.printStackTrace();
}

View File

@@ -3,13 +3,12 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2004-08 Ben Fry and Casey Reas
Copyright (c) 2004-09 Ben Fry and Casey Reas
Copyright (c) 2001-04 Massachusetts Institute of Technology
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -146,13 +145,22 @@ public class Editor extends JFrame implements RunnerListener {
// When bringing a window to front, let the Base know
addWindowListener(new WindowAdapter() {
public void windowActivated(WindowEvent e) {
// System.err.println("activate"); // not coming through
base.handleActivated(Editor.this);
// re-add the sub-menus that are shared by all windows
fileMenu.insert(sketchbookMenu, 2);
fileMenu.insert(examplesMenu, 3);
sketchMenu.insert(importMenu, 4);
}
// added for 1.0.5
// http://dev.processing.org/bugs/show_bug.cgi?id=1260
public void windowDeactivated(WindowEvent e) {
// System.err.println("deactivate"); // not coming through
fileMenu.remove(sketchbookMenu);
fileMenu.remove(examplesMenu);
sketchMenu.remove(importMenu);
}
});
//PdeKeywords keywords = new PdeKeywords();
@@ -437,26 +445,15 @@ public class Editor extends JFrame implements RunnerListener {
});
fileMenu.add(item);
boolean nativeButBroken = Base.isMacOS() ?
Preferences.getBoolean("apple.laf.useScreenMenuBar") : false;
if (sketchbookMenu == null) {
sketchbookMenu = new JMenu("Sketchbook");
if (nativeButBroken) {
sketchbookMenu.setEnabled(false);
} else {
base.rebuildSketchbookMenu(sketchbookMenu);
}
base.rebuildSketchbookMenu(sketchbookMenu);
}
fileMenu.add(sketchbookMenu);
if (examplesMenu == null) {
examplesMenu = new JMenu("Examples");
if (nativeButBroken) {
examplesMenu.setEnabled(false);
} else {
base.rebuildExamplesMenu(examplesMenu);
}
base.rebuildExamplesMenu(examplesMenu);
}
fileMenu.add(examplesMenu);