mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Set sketch as modified when any character committed using input method support
This commit is contained in:
@@ -1173,4 +1173,12 @@ public abstract class InputHandler extends KeyAdapter
|
||||
}
|
||||
return wordEnd;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when input method support committed a character.
|
||||
* @param c The input character
|
||||
*/
|
||||
public void onCommittedFromInputMethodSupport(char c) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,6 +193,12 @@ public class JEditTextArea extends JComponent
|
||||
if (Preferences.getBoolean("editor.input_method_support")) {
|
||||
if (inputMethodSupport == null) {
|
||||
inputMethodSupport = new InputMethodSupport(this);
|
||||
inputMethodSupport.setCallback(new InputMethodSupport.Callback() {
|
||||
@Override
|
||||
public void onCommitted(char c) {
|
||||
inputHandler.onCommittedFromInputMethodSupport(c);
|
||||
}
|
||||
});
|
||||
}
|
||||
return inputMethodSupport;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,10 @@ import processing.app.syntax.TextAreaPainter;
|
||||
*/
|
||||
public class InputMethodSupport implements InputMethodRequests, InputMethodListener {
|
||||
|
||||
public interface Callback {
|
||||
public void onCommitted(char c);
|
||||
}
|
||||
|
||||
static private final Attribute[] CUSTOM_IM_ATTRIBUTES = {
|
||||
TextAttribute.INPUT_METHOD_HIGHLIGHT,
|
||||
};
|
||||
@@ -47,6 +51,7 @@ public class InputMethodSupport implements InputMethodRequests, InputMethodListe
|
||||
private int committedCount = 0;
|
||||
private JEditTextArea textArea;
|
||||
private AttributedString composedTextString;
|
||||
private Callback callback;
|
||||
|
||||
public InputMethodSupport(JEditTextArea textArea) {
|
||||
this.textArea = textArea;
|
||||
@@ -55,6 +60,11 @@ public class InputMethodSupport implements InputMethodRequests, InputMethodListe
|
||||
}
|
||||
|
||||
|
||||
public void setCallback(Callback callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// InputMethodRequest
|
||||
@@ -170,6 +180,8 @@ public class InputMethodSupport implements InputMethodRequests, InputMethodListe
|
||||
char c = text.first();
|
||||
while (remaining-- > 0) {
|
||||
insertCharacter(c);
|
||||
if (callback != null)
|
||||
callback.onCommitted(c);
|
||||
c = text.next();
|
||||
}
|
||||
|
||||
|
||||
@@ -334,6 +334,13 @@ public class JavaInputHandler extends PdeInputHandler {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCommittedFromInputMethodSupport(char c) {
|
||||
Sketch sketch = editor.getSketch();
|
||||
sketch.setModified(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the index for the first character on this line.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user