From c9d4c761bbc2ca17ca4fa69c1d2e20917f14f6ff Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 14 Sep 2013 19:51:15 +0800 Subject: [PATCH] Show IME's composition text on screen. The composition text should only show on screen temporarily and gets disappered when input is cancelled or done. We simply mark the composition as selected, so it can not only indicate this is composition text instead of normal text, but also updates the composition without adding new interfaces. --- src/editor.coffee | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/editor.coffee b/src/editor.coffee index 15a86f5a4..b14ae350b 100644 --- a/src/editor.coffee +++ b/src/editor.coffee @@ -699,7 +699,18 @@ class Editor extends View handleImeEvents: -> @on 'cursor:moved', => - @hiddenInput.offset(@getCursorView().offset()) + cursorView = @getCursorView() + @hiddenInput.offset(cursorView.offset()) if cursorView.is(':visible') + + startScreenPosition = null + @hiddenInput.on 'compositionstart', => + startScreenPosition = @getCursorScreenPosition() + @hiddenInput.on 'compositionupdate', (e) => + @insertText(e.originalEvent.data) + @selectToScreenPosition(startScreenPosition) + @hiddenInput.on 'compositionend', => + @delete() + startScreenPosition = null selectOnMousemoveUntilMouseup: -> lastMoveEvent = null