Skip to content

Commit

Permalink
Avoid IME issue after "Edit comment" in featurecat#880
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiraoka committed Mar 11, 2021
1 parent 9b53d93 commit 32436d5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/featurecat/lizzie/gui/MainFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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() {
Expand Down

0 comments on commit 32436d5

Please sign in to comment.