mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
move input method callback since it's broadly applicable
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user