Skip to content

Commit a859cfb

Browse files
author
Federico Fissore
committed
Middle mouse button pastes text only on linux: on other OSs it does nothing. Fixes #3266
1 parent 8cfaf3c commit a859cfb

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package processing.app.syntax;
2+
3+
import org.fife.ui.rtextarea.ConfigurableCaret;
4+
import processing.app.helpers.OSUtils;
5+
6+
import javax.swing.*;
7+
import java.awt.event.MouseEvent;
8+
9+
public class MyConfigurableCaret extends ConfigurableCaret {
10+
11+
@Override
12+
public void mouseClicked(MouseEvent e) {
13+
if (e.isConsumed()) {
14+
return;
15+
}
16+
17+
if (!OSUtils.isLinux() && SwingUtilities.isMiddleMouseButton(e)) {
18+
return;
19+
}
20+
21+
super.mouseClicked(e);
22+
}
23+
}

app/src/processing/app/syntax/SketchTextAreaUI.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.fife.ui.rsyntaxtextarea.RSyntaxTextAreaUI;
44

55
import javax.swing.*;
6+
import javax.swing.text.Caret;
67
import javax.swing.text.EditorKit;
78
import javax.swing.text.JTextComponent;
89

@@ -18,4 +19,11 @@ public SketchTextAreaUI(JComponent rSyntaxTextArea) {
1819
public EditorKit getEditorKit(JTextComponent tc) {
1920
return defaultKit;
2021
}
22+
23+
@Override
24+
protected Caret createCaret() {
25+
Caret caret = new MyConfigurableCaret();
26+
caret.setBlinkRate(500);
27+
return caret;
28+
}
2129
}

0 commit comments

Comments
 (0)