-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
jfx18
-
x86_64
-
linux
ADDITIONAL SYSTEM INFORMATION :
Mac Big sure
Linux mint 20.3 cinnamon
A DESCRIPTION OF THE PROBLEM :
Mac: when create a text field or text area runtime not startup, and focus them with code not mouse, input chinese, the english pinyin also will commited to text, if I put nihao, the text controls will show nihao你好, the true result must be 你好 not nihao你好
Warn: If we refocus this text control, by example, you click other controls and then click this text control again, the text control will work right. So it's hard to find this bug
Rember two key: create controls runtime and first focus it with code.
So I change to linux, but I got worse result.
I install rime and it work well in all software except javafx.
I search a lot of information, finally I only find -Djdk.gtk.version=2
like mac problem, one different, in linux, when create controls runtime and try to switch input method, nothing happen, I also can refocus it let it work right like mac.
But gtk 2 will remove future.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.geometry.Point2D;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.input.InputMethodRequests;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
// this two textfield just for Compared
VBox vBox = new VBox(new TextField(),new Button(), new TextField());
var b = new Button();
// I want to make my own text controls for mac but faild in linux
vBox.setInputMethodRequests(new InputMethodRequests() {
@Override
public Point2D getTextLocation(int offset) {
return new Point2D(50,50);
}
@Override
public int getLocationOffset(int x, int y) {
return 0;
}
@Override
public void cancelLatestCommittedText() {
}
@Override
public String getSelectedText() {
return null;
}
});
vBox.setOnInputMethodTextChanged(e -> {
System.out.println(e.getCommitted());
});
vBox.setFocusTraversable(true);
vBox.setOnMouseClicked(e -> {
vBox.requestFocus();
// this is main test part for mac and linux
var t = new TextField("dfsf");
vBox.getChildren().add(t);
t.requestFocus();
System.out.println("d");
});
vBox.setOnKeyTyped(e -> {
System.out.println(e.getCharacter());
});
primaryStage.setScene(new Scene(vBox));
primaryStage.show();
}
}
-Djdk.gtk.version=2
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
It's frustrating me. I love javafx. But without right text controls, I can't make anything interactive.
I don't want to change to Windows. I try my best to solve this problem. Finally I find it beyond my capabilities.
If you are too busy to solve input method problem, can you tell me which module source may cause the problem, may be I should modify open javafx source code and do this by myself.
FREQUENCY : always
Mac Big sure
Linux mint 20.3 cinnamon
A DESCRIPTION OF THE PROBLEM :
Mac: when create a text field or text area runtime not startup, and focus them with code not mouse, input chinese, the english pinyin also will commited to text, if I put nihao, the text controls will show nihao你好, the true result must be 你好 not nihao你好
Warn: If we refocus this text control, by example, you click other controls and then click this text control again, the text control will work right. So it's hard to find this bug
Rember two key: create controls runtime and first focus it with code.
So I change to linux, but I got worse result.
I install rime and it work well in all software except javafx.
I search a lot of information, finally I only find -Djdk.gtk.version=2
like mac problem, one different, in linux, when create controls runtime and try to switch input method, nothing happen, I also can refocus it let it work right like mac.
But gtk 2 will remove future.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.geometry.Point2D;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.input.InputMethodRequests;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
// this two textfield just for Compared
VBox vBox = new VBox(new TextField(),new Button(), new TextField());
var b = new Button();
// I want to make my own text controls for mac but faild in linux
vBox.setInputMethodRequests(new InputMethodRequests() {
@Override
public Point2D getTextLocation(int offset) {
return new Point2D(50,50);
}
@Override
public int getLocationOffset(int x, int y) {
return 0;
}
@Override
public void cancelLatestCommittedText() {
}
@Override
public String getSelectedText() {
return null;
}
});
vBox.setOnInputMethodTextChanged(e -> {
System.out.println(e.getCommitted());
});
vBox.setFocusTraversable(true);
vBox.setOnMouseClicked(e -> {
vBox.requestFocus();
// this is main test part for mac and linux
var t = new TextField("dfsf");
vBox.getChildren().add(t);
t.requestFocus();
System.out.println("d");
});
vBox.setOnKeyTyped(e -> {
System.out.println(e.getCharacter());
});
primaryStage.setScene(new Scene(vBox));
primaryStage.show();
}
}
-Djdk.gtk.version=2
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
It's frustrating me. I love javafx. But without right text controls, I can't make anything interactive.
I don't want to change to Windows. I try my best to solve this problem. Finally I find it beyond my capabilities.
If you are too busy to solve input method problem, can you tell me which module source may cause the problem, may be I should modify open javafx source code and do this by myself.
FREQUENCY : always
- duplicates
-
JDK-8263955 [macos] pinyin input method not working when textfield.requestfocus()
-
- Closed
-