Skip to content

Commit 7ae377d

Browse files
committed
Do not clear serial monitor when disabled for upload (@PaulStoffregen)
Fix #9234
1 parent 0064169 commit 7ae377d

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

app/src/processing/app/AbstractTextMonitor.java

+22-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static processing.app.I18n.tr;
44

55
import java.awt.BorderLayout;
6+
import java.awt.Color;
67
import java.awt.Container;
78
import java.awt.Dimension;
89
import java.awt.Font;
@@ -170,9 +171,27 @@ public void windowGainedFocus(WindowEvent e) {
170171
}
171172

172173
@Override
173-
protected void onEnableWindow(boolean enable)
174-
{
175-
textArea.setEnabled(enable);
174+
protected void onEnableWindow(boolean enable) {
175+
Thread.dumpStack();
176+
System.out.println("onEnableWindow " + enable);
177+
// never actually disable textArea, so people can
178+
// still select & copy text, even when the port
179+
// is closed or disconnected
180+
textArea.setEnabled(true);
181+
if (enable) {
182+
// setting these to null for system default
183+
// gives a wrong gray background on Windows
184+
// so assume black text on white background
185+
textArea.setForeground(Color.BLACK);
186+
textArea.setBackground(Color.WHITE);
187+
} else {
188+
// In theory, UIManager.getDefaults() should
189+
// give us the system's colors for disabled
190+
// windows. But it doesn't seem to work. :(
191+
textArea.setForeground(new Color(64, 64, 64));
192+
textArea.setBackground(new Color(238, 238, 238));
193+
}
194+
textArea.invalidate();
176195
clearButton.setEnabled(enable);
177196
scrollPane.setEnabled(enable);
178197
textField.setEnabled(enable);

app/src/processing/app/SerialMonitor.java

-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ public void close() throws Exception {
142142
int[] location = getPlacement();
143143
String locationStr = PApplet.join(PApplet.str(location), ",");
144144
PreferencesData.set("last.serial.location", locationStr);
145-
textArea.setText("");
146145
serial.dispose();
147146
serial = null;
148147
}

0 commit comments

Comments
 (0)