mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-21 12:29:23 +01:00
Fix for full-width space bug.
Imported from Processing development r6687 on http://code.google.com/p/processing Close #1
This commit is contained in:
parent
541a7b3575
commit
7b8888a93a
@ -54,6 +54,18 @@ public class CompositionTextManager {
|
||||
public boolean getIsInputProcess() {
|
||||
return isInputProcess;
|
||||
}
|
||||
/**
|
||||
* Insert full width space
|
||||
*/
|
||||
public void insertFullWidthSpace() {
|
||||
initialCaretPosition = textArea.getCaretPosition();
|
||||
int layoutCaretPosition = initialCaretPosition;
|
||||
try {
|
||||
textArea.getDocument().insertString(layoutCaretPosition, "\u3000", null);
|
||||
} catch (BadLocationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a user begins input from input method.
|
||||
@ -115,7 +127,6 @@ public class CompositionTextManager {
|
||||
* @param commited_count Numbers of committed characters in text.
|
||||
*/
|
||||
public void endCompositionText(AttributedCharacterIterator text, int committed_count) {
|
||||
isInputProcess = false;
|
||||
/*
|
||||
* If there are no committed characters, remove it all from textarea.
|
||||
* This case will happen if a user delete all composing characters by backspace or delete key.
|
||||
|
@ -73,6 +73,11 @@ public class InputMethodSupport implements InputMethodRequests,
|
||||
public void inputMethodTextChanged(InputMethodEvent event) {
|
||||
AttributedCharacterIterator text = event.getText();
|
||||
committed_count = event.getCommittedCharacterCount();
|
||||
if(isFullWidthSpaceInput(text)){
|
||||
textManager.insertFullWidthSpace();
|
||||
caretPositionChanged(event);
|
||||
return;
|
||||
}
|
||||
if(isBeginInputProcess(text, textManager)){
|
||||
textManager.beginCompositionText(text, committed_count);
|
||||
caretPositionChanged(event);
|
||||
@ -86,11 +91,21 @@ public class InputMethodSupport implements InputMethodRequests,
|
||||
textManager.endCompositionText(text, committed_count);
|
||||
caretPositionChanged(event);
|
||||
}
|
||||
|
||||
|
||||
private boolean isFullWidthSpaceInput(AttributedCharacterIterator text){
|
||||
if(text == null)
|
||||
return false;
|
||||
if(textManager.getIsInputProcess())
|
||||
return false;
|
||||
return (String.valueOf(text.first()).equals("\u3000"));
|
||||
}
|
||||
|
||||
private boolean isBeginInputProcess(AttributedCharacterIterator text, CompositionTextManager textManager){
|
||||
if(text == null)
|
||||
return false;
|
||||
return (isInputProcess(text) && !textManager.getIsInputProcess());
|
||||
if(textManager.getIsInputProcess())
|
||||
return false;
|
||||
return (isInputProcess(text));
|
||||
}
|
||||
|
||||
private boolean isInputProcess(AttributedCharacterIterator text){
|
||||
|
Loading…
x
Reference in New Issue
Block a user