* adjusted _HandleInputMethodChanged() to not blindly insert the string that
has been given via the inline input method, but to feed the individual UTF8-characters it contains to KeyDown() - this way special keys like B_BACKSPACE and cursor keys will be handled correctly instead of producing a "unknown char rectangle" git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30764 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -5250,22 +5250,52 @@ BTextView::_HandleInputMethodChanged(BMessage *message)
|
|||||||
clauseCount++;
|
clauseCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 selectionStart = 0;
|
if (confirmed) {
|
||||||
int32 selectionEnd = 0;
|
_Refresh(fSelStart, fSelEnd, true, true);
|
||||||
message->FindInt32("be:selection", 0, &selectionStart);
|
_ShowCaret();
|
||||||
message->FindInt32("be:selection", 1, &selectionEnd);
|
|
||||||
|
|
||||||
fInline->SetSelectionOffset(selectionStart);
|
// now we need to feed ourselves the individual characters as if the
|
||||||
fInline->SetSelectionLength(selectionEnd - selectionStart);
|
// user would have pressed them now - this lets KeyDown() pick out all
|
||||||
|
// the special characters like B_BACKSPACE, cursor keys and the like:
|
||||||
|
const char* currPos = string;
|
||||||
|
const char* prevPos = currPos;
|
||||||
|
while (*currPos != '\0') {
|
||||||
|
if ((*currPos & 0xC0) == 0xC0) {
|
||||||
|
// found the start of an UTF-8 char, we collect while it lasts
|
||||||
|
++currPos;
|
||||||
|
while ((*currPos & 0xC0) == 0x80)
|
||||||
|
++currPos;
|
||||||
|
} else if ((*currPos & 0xC0) == 0x80) {
|
||||||
|
// illegal: character starts with utf-8 intermediate byte, skip it
|
||||||
|
prevPos = ++currPos;
|
||||||
|
} else {
|
||||||
|
// single byte character/code, just feed that
|
||||||
|
++currPos;
|
||||||
|
}
|
||||||
|
KeyDown(prevPos, currPos - prevPos);
|
||||||
|
prevPos = currPos;
|
||||||
|
}
|
||||||
|
|
||||||
const int32 inlineOffset = fInline->Offset();
|
_Refresh(fSelStart, fSelEnd, true, true);
|
||||||
InsertText(string, stringLen, fSelStart, NULL);
|
} else {
|
||||||
fSelStart += stringLen;
|
// temporarily show transient state of inline input
|
||||||
fClickOffset = fSelEnd = fSelStart;
|
int32 selectionStart = 0;
|
||||||
|
int32 selectionEnd = 0;
|
||||||
|
message->FindInt32("be:selection", 0, &selectionStart);
|
||||||
|
message->FindInt32("be:selection", 1, &selectionEnd);
|
||||||
|
|
||||||
_Refresh(inlineOffset, fSelEnd, true, true);
|
fInline->SetSelectionOffset(selectionStart);
|
||||||
|
fInline->SetSelectionLength(selectionEnd - selectionStart);
|
||||||
|
|
||||||
|
const int32 inlineOffset = fInline->Offset();
|
||||||
|
InsertText(string, stringLen, fSelStart, NULL);
|
||||||
|
fSelStart += stringLen;
|
||||||
|
fClickOffset = fSelEnd = fSelStart;
|
||||||
|
|
||||||
|
_Refresh(inlineOffset, fSelEnd, true, true);
|
||||||
|
_ShowCaret();
|
||||||
|
}
|
||||||
|
|
||||||
_ShowCaret();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user