mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-15 12:29:26 +01:00
Merge pull request #8023 from facchinm/new_behaviour_osx_close
[macOS] Modify behaviour when last editor gets closed
This commit is contained in:
commit
c311a94e7b
@ -49,6 +49,7 @@ import processing.app.debug.TargetBoard;
|
|||||||
import processing.app.debug.TargetPackage;
|
import processing.app.debug.TargetPackage;
|
||||||
import processing.app.debug.TargetPlatform;
|
import processing.app.debug.TargetPlatform;
|
||||||
import processing.app.helpers.*;
|
import processing.app.helpers.*;
|
||||||
|
import processing.app.helpers.OSUtils;
|
||||||
import processing.app.helpers.filefilters.OnlyDirs;
|
import processing.app.helpers.filefilters.OnlyDirs;
|
||||||
import processing.app.helpers.filefilters.OnlyFilesWithExtension;
|
import processing.app.helpers.filefilters.OnlyFilesWithExtension;
|
||||||
import processing.app.javax.swing.filechooser.FileNameExtensionFilter;
|
import processing.app.javax.swing.filechooser.FileNameExtensionFilter;
|
||||||
@ -931,15 +932,14 @@ public class Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (editors.size() == 1) {
|
if (editors.size() == 1) {
|
||||||
|
editor.setVisible(false);
|
||||||
|
editors.remove(editor);
|
||||||
handleQuit();
|
handleQuit();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// More than one editor window open,
|
// More than one editor window open,
|
||||||
// proceed with closing the current window.
|
// proceed with closing the current window.
|
||||||
editor.setVisible(false);
|
editor.setVisible(false);
|
||||||
editor.dispose();
|
editor.dispose();
|
||||||
|
|
||||||
editors.remove(editor);
|
editors.remove(editor);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -974,7 +974,7 @@ public class Base {
|
|||||||
// Save out the current prefs state
|
// Save out the current prefs state
|
||||||
PreferencesData.save();
|
PreferencesData.save();
|
||||||
|
|
||||||
if (!OSUtils.hasMacOSStyleMenus()) {
|
if (!OSUtils.isMacOS()) {
|
||||||
// If this was fired from the menu or an AppleEvent (the Finder),
|
// If this was fired from the menu or an AppleEvent (the Finder),
|
||||||
// then Mac OS X will send the terminate signal itself.
|
// then Mac OS X will send the terminate signal itself.
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
package processing.app.macosx;
|
package processing.app.macosx;
|
||||||
|
|
||||||
import com.apple.eawt.*;
|
import com.apple.eawt.*;
|
||||||
|
import com.apple.eawt.AppEvent.AppReOpenedEvent;
|
||||||
|
|
||||||
import processing.app.Base;
|
import processing.app.Base;
|
||||||
import processing.app.Editor;
|
import processing.app.Editor;
|
||||||
|
|
||||||
@ -45,6 +47,20 @@ public class ThinkDifferent {
|
|||||||
|
|
||||||
static public void init() {
|
static public void init() {
|
||||||
Application application = Application.getApplication();
|
Application application = Application.getApplication();
|
||||||
|
|
||||||
|
application.addAppEventListener(new AppReOpenedListener() {
|
||||||
|
@Override
|
||||||
|
public void appReOpened(AppReOpenedEvent aroe) {
|
||||||
|
try {
|
||||||
|
if (Base.INSTANCE.getEditors().size() == 0) {
|
||||||
|
Base.INSTANCE.handleNew();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
application.setAboutHandler(new AboutHandler() {
|
application.setAboutHandler(new AboutHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleAbout(AppEvent.AboutEvent aboutEvent) {
|
public void handleAbout(AppEvent.AboutEvent aboutEvent) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user