diff --git a/src/TSMapEditor/UI/IME/IMEHandler.cs b/src/TSMapEditor/UI/IME/IMEHandler.cs index b2bc5d70..26ada1a7 100644 --- a/src/TSMapEditor/UI/IME/IMEHandler.cs +++ b/src/TSMapEditor/UI/IME/IMEHandler.cs @@ -79,28 +79,6 @@ protected virtual void OnIMETextInput(char character) LastActionIMEChatInput = true; - // Handle ESC. The IME reports ESC key as a text input. - if (character == 27) - { - LastActionIMEChatInput = false; - if (HandleEscapeKey()) - { - // Do not return this ESC key back to the textbox if HandleEscapeKey returns true. - return; - } - else - { - // handleChatInput() method rejects the ESC message. Therefore, we need to manually clear the TextBox here. - if (IMEFocus != null) - { - // TODO: wrap this logic as a new action in RegisterXNATextBox(). This requires an API breaking change on XNAUI, and therefore left as a TODO. - IMEFocus.Text = string.Empty; - } - - return; - } - } - if (IMEFocus != null) { TextBoxHandleChatInputCallbacks.TryGetValue(IMEFocus, out var handleChatInput); @@ -228,21 +206,17 @@ bool IIMEHandler.HandleEnterKey(XNATextBox sender) => false; bool IIMEHandler.HandleEscapeKey(XNATextBox sender) - { - return HandleEscapeKey(); - } - - private bool HandleEscapeKey() { //Debug.WriteLine($"IME: HandleEscapeKey: handled: {IMEEventReceived}"); - // This method disables the ESC handling of the TextBox as long as the user has used IME. - // This is because IME users often use ESC to cancel composition, and even if currently the composition is empty, + // This method disables the ESC handling of the TextBox as long as the user has ever used IME. + // This is because IME users often use ESC to cancel composition. Even if currently the composition is empty, // the user still expects ESC to cancel composition rather than deleting the whole sentence. // For example, the user might mistakenly hit ESC key twice to cancel composition -- deleting the whole sentence is definitely a heavy punishment for such a small mistake. - // Note: "!string.IsNullOrEmpty(Composition) =>IMEEventReceived" should hold, but just in case - return IMEEventReceived || !string.IsNullOrEmpty(Composition); + // Note: "!CompositionEmpty => IMEEventReceived" should hold, but just in case + + return IMEEventReceived || !CompositionEmpty; } void IIMEHandler.OnTextChanged(XNATextBox sender) { }