Skip to content

Commit 8369507

Browse files
committed
finishInputMethodComposition is only called when focus changes on the event scene
1 parent 786201d commit 8369507

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

modules/javafx.graphics/src/main/java/com/sun/javafx/scene/InputMethodStateManager.java

+16-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ public InputMethodStateManager(Scene scene) {
8888
}
8989

9090
/**
91-
* Add a new Scene to the stack. It is assumed that Scenes form a stack
92-
* and leave in LIFO order.
91+
* Add a new Scene to the stack.
9392
*/
9493
public void addScene(Scene scene) {
9594
if (scenes.contains(scene)) {
@@ -99,6 +98,9 @@ public void addScene(Scene scene) {
9998
updateInputMethodEventEnableState();
10099
}
101100

101+
/**
102+
* Remove a Scene from the stack.
103+
*/
102104
public void removeScene(Scene scene) {
103105
if (scene != scenes.peekFirst()) {
104106
System.err.println("Popup scene removed out of order");
@@ -120,6 +122,18 @@ public void removeScene(Scene scene) {
120122
updateInputMethodEventEnableState();
121123
}
122124

125+
/**
126+
* Every Scene must call this before the focusOwner changes.
127+
*/
128+
public void focusOwnerWillChangeForScene(Scene scene) {
129+
if (scene == currentEventScene) {
130+
Scene root = rootScene.get();
131+
if (root != null) {
132+
SceneHelper.finishInputMethodComposition(root);
133+
}
134+
}
135+
}
136+
123137
/**
124138
* Every Scene must call this when the focusOwner changes.
125139
*/

modules/javafx.graphics/src/main/java/javafx/scene/Scene.java

+1-7
Original file line numberDiff line numberDiff line change
@@ -2329,13 +2329,7 @@ private void setFocusOwner(Node node, boolean focusVisible) {
23292329
// This needs to be done before the focus owner is switched as it
23302330
// generates event that needs to be delivered to the old focus owner.
23312331
if (focusOwner.oldFocusOwner != null) {
2332-
final Scene s = getInputMethodStateManager().getRootScene();
2333-
if (s != null) {
2334-
final TKScene peer = s.getPeer();
2335-
if (peer != null) {
2336-
peer.finishInputMethodComposition();
2337-
}
2338-
}
2332+
getInputMethodStateManager().focusOwnerWillChangeForScene(this);
23392333
}
23402334

23412335
// Store the current focusVisible state of the focus owner in case it needs to be

0 commit comments

Comments
 (0)