From 32436d560eaab40eb760cf4371d58f22f79ae6fa Mon Sep 17 00:00:00 2001 From: Hiraoka Date: Thu, 11 Mar 2021 20:10:47 +0900 Subject: [PATCH] Avoid IME issue after "Edit comment" in #880 --- src/main/java/featurecat/lizzie/gui/MainFrame.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/featurecat/lizzie/gui/MainFrame.java b/src/main/java/featurecat/lizzie/gui/MainFrame.java index 69c91ea1..7f0e2f4f 100644 --- a/src/main/java/featurecat/lizzie/gui/MainFrame.java +++ b/src/main/java/featurecat/lizzie/gui/MainFrame.java @@ -18,6 +18,7 @@ import java.awt.datatransfer.Transferable; import java.awt.event.MouseEvent; import java.awt.event.MouseWheelEvent; +import java.awt.im.InputContext; import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -162,6 +163,12 @@ public void addSuggestionAsBranch() {} public abstract void pasteSgf(); public void editComment() { + InputContext context = InputContext.getInstance(); + boolean oldCompositionEnabled = false; + try { + oldCompositionEnabled = context.isCompositionEnabled(); + } catch (UnsupportedOperationException e) { + } String oldComment = Lizzie.board.getHistory().getData().comment; // https://stackoverflow.com/questions/7765478/how-to-add-text-area-on-joptionpane // https://stackoverflow.com/a/55678093 @@ -178,6 +185,10 @@ public void editComment() { Lizzie.board.getHistory().getData().comment = textArea.getText(); refresh(); } + try { + context.setCompositionEnabled(oldCompositionEnabled); + } catch (UnsupportedOperationException e) { + } } public void copyCommentToClipboard() {