Skip to content
Permalink
Browse files

Clear selection & caret position when clearing window

  • Loading branch information...
PaulStoffregen committed Sep 8, 2019
1 parent 3f2dd15 commit e203e8cfa87377d1d5839da852bc3a6ab62d880c
Showing with 9 additions and 3 deletions.
  1. +9 −3 app/src/processing/app/TeensyPipeMonitor.java
@@ -65,7 +65,7 @@ public TeensyPipeMonitor(BoardPort port) {

onClearCommand(new ActionListener() {
public void actionPerformed(ActionEvent e) {
textArea.setText("");
clear();
}
});
onSendCommand(new ActionListener() {
@@ -99,6 +99,12 @@ public void windowClosing(WindowEvent event) {
});
}

private void clear() {
textArea.select(0, 0);
textArea.setCaretPosition(0);
textArea.setText("");
}

public void open() throws Exception {
String port = getBoardPort().getAddress();
if (debug) System.out.println("TeensyPipeMonitor open " + port);
@@ -134,7 +140,7 @@ public void open() throws Exception {
}
if (program != null) {
openport = new String(port);
textArea.setText("");
clear();
listener = new inputPipeListener();
listener.input = program.getInputStream();
listener.output = this;
@@ -168,7 +174,7 @@ public void close() throws Exception {

public void opened(String device, String usbtype) {
if (debug) System.out.println("opened, dev=" + device + ", name=" + usbtype);
textArea.setText("");
clear();
setTitle(device + " (" + teensyname + ") " + usbtype);
// setting these to null for system default
// gives a wrong gray background on Windows

0 comments on commit e203e8c

Please sign in to comment.
You can’t perform that action at this time.