From a859cfb9f9b659578dfcb23f3e9ccf026ff820d1 Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Mon, 1 Jun 2015 14:25:00 +0200 Subject: [PATCH] Middle mouse button pastes text only on linux: on other OSs it does nothing. Fixes #3266 --- .../app/syntax/MyConfigurableCaret.java | 23 +++++++++++++++++++ .../app/syntax/SketchTextAreaUI.java | 8 +++++++ 2 files changed, 31 insertions(+) create mode 100644 app/src/processing/app/syntax/MyConfigurableCaret.java diff --git a/app/src/processing/app/syntax/MyConfigurableCaret.java b/app/src/processing/app/syntax/MyConfigurableCaret.java new file mode 100644 index 000000000..87cc5c546 --- /dev/null +++ b/app/src/processing/app/syntax/MyConfigurableCaret.java @@ -0,0 +1,23 @@ +package processing.app.syntax; + +import org.fife.ui.rtextarea.ConfigurableCaret; +import processing.app.helpers.OSUtils; + +import javax.swing.*; +import java.awt.event.MouseEvent; + +public class MyConfigurableCaret extends ConfigurableCaret { + + @Override + public void mouseClicked(MouseEvent e) { + if (e.isConsumed()) { + return; + } + + if (!OSUtils.isLinux() && SwingUtilities.isMiddleMouseButton(e)) { + return; + } + + super.mouseClicked(e); + } +} diff --git a/app/src/processing/app/syntax/SketchTextAreaUI.java b/app/src/processing/app/syntax/SketchTextAreaUI.java index 7ae86a102..0f23e3145 100644 --- a/app/src/processing/app/syntax/SketchTextAreaUI.java +++ b/app/src/processing/app/syntax/SketchTextAreaUI.java @@ -3,6 +3,7 @@ package processing.app.syntax; import org.fife.ui.rsyntaxtextarea.RSyntaxTextAreaUI; import javax.swing.*; +import javax.swing.text.Caret; import javax.swing.text.EditorKit; import javax.swing.text.JTextComponent; @@ -18,4 +19,11 @@ public class SketchTextAreaUI extends RSyntaxTextAreaUI { public EditorKit getEditorKit(JTextComponent tc) { return defaultKit; } + + @Override + protected Caret createCaret() { + Caret caret = new MyConfigurableCaret(); + caret.setBlinkRate(500); + return caret; + } }