move input method callback since it's broadly applicable

This commit is contained in:
Ben Fry
2016-08-05 10:50:19 -04:00
parent 01b1bc7041
commit a223822949
4 changed files with 23 additions and 12 deletions
@@ -30,6 +30,7 @@ import java.awt.event.KeyEvent;
import processing.app.Platform;
import processing.app.Preferences;
import processing.app.ui.Editor;
/**
@@ -39,7 +40,17 @@ import processing.app.Preferences;
*/
public class PdeInputHandler extends DefaultInputHandler {
public PdeInputHandler() {
/**
* Need the Editor object for Input Method changes, plus most subclasses
* will want a local copy anyway. Changed after Processing 3.1.2, need to
* see if this breaks any other Modes before releasing.
*/
protected Editor editor;
public PdeInputHandler(Editor editor) {
this.editor = editor;
// Use option on mac for text edit controls that are ctrl on Windows/Linux.
// (i.e. ctrl-left/right is option-left/right on OS X)
String mod = Platform.isMacOS() ? "A" : "C";
@@ -253,4 +264,9 @@ public class PdeInputHandler extends DefaultInputHandler {
public boolean handleTyped(KeyEvent event) {
return false;
}
public void handleInputMethodCommit() {
editor.getSketch().setModified(true);
}
}
+3 -3
View File
@@ -389,7 +389,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
protected JEditTextArea createTextArea() {
return new JEditTextArea(new PdeTextAreaDefaults(mode),
new PdeInputHandler());
new PdeInputHandler(this));
}
@@ -1770,7 +1770,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
startCompoundEdit();
super.beginCompoundEdit();
}
@Override
public void endCompoundEdit() {
stopCompoundEdit();
@@ -1805,7 +1805,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
if (!isInserting && !textarea.isOverwriteEnabled() && isDirectEdit()) {
endTextEditHistory();
}
if (!textarea.isOverwriteEnabled()) {
isInserting = true;
}
@@ -40,7 +40,6 @@ import java.util.Arrays;
* continuing to hack this class.
*/
public class JavaInputHandler extends PdeInputHandler {
private Editor editor;
/** ctrl-alt on windows and linux, cmd-alt on mac os x */
static final int CTRL_ALT = ActionEvent.ALT_MASK |
@@ -48,7 +47,7 @@ public class JavaInputHandler extends PdeInputHandler {
public JavaInputHandler(Editor editor) {
this.editor = editor;
super(editor);
}
@@ -334,12 +333,6 @@ public class JavaInputHandler extends PdeInputHandler {
}
@Override
public void handleInputMethodCommit() {
editor.getSketch().setModified(true);
}
/**
* Return the index for the first character on this line.
*/
+2
View File
@@ -1,4 +1,6 @@
0252 (3.1.3?)
X change PdeInputHandler constructor
_ check whether this breaks other Modes before releasing
_ modify line number color when no lines extend that far?
_ https://github.com/processing/processing/pull/4560
_ text gutter doesn't seem to be hidpi