|
86 | 86 | * Main editor panel for the Processing Development Environment.
|
87 | 87 | */
|
88 | 88 | @SuppressWarnings("serial")
|
89 |
| -public class Editor extends JFrame implements RunnerListener, FocusListener { |
| 89 | +public class Editor extends JFrame implements RunnerListener { |
90 | 90 |
|
91 | 91 | public static final int MAX_TIME_AWAITING_FOR_RESUMING_SERIAL_MONITOR = 10000;
|
92 | 92 |
|
@@ -237,12 +237,20 @@ public void windowClosing(WindowEvent e) {
|
237 | 237 | // When bringing a window to front, let the Base know
|
238 | 238 | addWindowListener(new WindowAdapter() {
|
239 | 239 | public void windowActivated(WindowEvent e) {
|
| 240 | + if (watcher != null) { |
| 241 | + watcher.interrupt(); |
| 242 | + watcher = null; |
| 243 | + } |
240 | 244 | base.handleActivated(Editor.this);
|
241 | 245 | }
|
242 | 246 |
|
243 | 247 | // added for 1.0.5
|
244 | 248 | // http://dev.processing.org/bugs/show_bug.cgi?id=1260
|
245 | 249 | public void windowDeactivated(WindowEvent e) {
|
| 250 | + if (watcher == null) { |
| 251 | + watcher = new Thread(task); |
| 252 | + watcher.start(); |
| 253 | + } |
246 | 254 | fileMenu.remove(sketchbookMenu);
|
247 | 255 | fileMenu.remove(examplesMenu);
|
248 | 256 | List<Component> toolsMenuItemsToRemove = new LinkedList<>();
|
@@ -363,22 +371,6 @@ public Base getBase() {
|
363 | 371 | return base;
|
364 | 372 | }
|
365 | 373 |
|
366 |
| - @Override |
367 |
| - public void focusGained(FocusEvent fe){ |
368 |
| - if (watcher != null) { |
369 |
| - watcher.interrupt(); |
370 |
| - watcher = null; |
371 |
| - } |
372 |
| - } |
373 |
| - |
374 |
| - @Override |
375 |
| - public void focusLost(FocusEvent fe){ |
376 |
| - if (watcher == null) { |
377 |
| - watcher = new Thread(task); |
378 |
| - watcher.start(); |
379 |
| - } |
380 |
| - } |
381 |
| - |
382 | 374 | /**
|
383 | 375 | * Handles files dragged & dropped from the desktop and into the editor
|
384 | 376 | * window. Dragging files into the editor window is the same as using
|
@@ -2016,10 +2008,6 @@ public void run() {
|
2016 | 2008 | }
|
2017 | 2009 | };
|
2018 | 2010 |
|
2019 |
| - addFocusListener(this); |
2020 |
| - getTabs().forEach(tab -> tab.getScrollPane().addFocusListener(this)); |
2021 |
| - getTabs().forEach(tab -> tab.getTextArea().addFocusListener(this)); |
2022 |
| - |
2023 | 2011 | // opening was successful
|
2024 | 2012 | return true;
|
2025 | 2013 | }
|
|
0 commit comments