-
Notifications
You must be signed in to change notification settings - Fork 542
8368478: RichTextArea: add IME support #1938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8368478: RichTextArea: add IME support #1938
Conversation
|
👋 Welcome back angorya! A progress list of the required criteria for merging this PR into |
|
@andy-goryachev-oracle This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 1 new commit pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
|
@andy-goryachev-oracle |
Webrevs
|
|
@lukostyra Can you also review? |
lukostyra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I tested this on Windows with rich editor demo and using both polish and spanish IME shortcuts - all work fine after this change
I wrote this comment on Windows and something shorted in my brain when I was typing this. I meant on Linux, Ubuntu 24.04.2 :) |
|
On Mac and Linux dead key sequences are delivered as InputMethodEvents. When typing ü using dead keys the user previews the diacritic mark (¨) as composed text and then the final character (ü) is delivered as committed text. |
|
Does it show any underline/dotted shapes? How do you type ü in German layout (on macOS)? edit: Please disregard, I see it! Typing + or shift-+ (using the US keyboard) shows an IME composition shape. |
|
I usually test using a US keyboard and typing Option+e for ´ or Option+u for ¨ or Option+n for ˜ |
As for Spanish, the method I use is to press One more IME check I also do borrows from this old commit replacing XIM with IBus and refers to Chinese (Pinyin) keyboard layout, simply trying to type "ni hao" - without IME this produces that exact text using latin alphabet, while with properly working IME it gets converted to respective Chinese characters. In case of RTA, without this change Polish diacritics worked fine, but Spanish ones did not and Chinese keyboard produced latin characters. This change makes both the Spanish shortcut and Chinese character conversion work properly. |
kevinrushforth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works as expected on macOS (I'll try it on Windows later). I left a few comments, mostly about the line separator as it relates to the private getText(...) method in RichTextArea.
| accessor = a; | ||
| } | ||
|
|
||
| public static boolean getText(RichTextArea t, TextPos start, TextPos end, StringBuilder sb, int limit, String lineSeparator) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the lineSeparator parameter really needed here? If not, I recommend removing it.
| dy = f.snappedTopInset(); | ||
|
|
||
| p = f.rangeShape(start, end); | ||
| p = f.rangeShape(start, end); // TODO new api, no null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this "TODO" really related to IME? If not, I recommend removing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code predates JDK-8357594
Additional geometry-based Text/TextFlow APIs. I am planning to migrate to the new API in a follow-up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for filing the RFE. Since you aren't otherwise modifying this method in this PR, adding a random TODO like this seems like an unrelated change. Now if you meant to also add this comment to line 232 (the call to f.getUnderlineShape(start, end) that you added above), then I could see also adding a reminder here as well.
So I recommend either adding a similar comment on line 232, or removing the unrelated TODOs.
| * @param end the end position | ||
| * @param sb the buffer to copy to | ||
| * @param limit the maximum number of characters to copy, must be >= 0 | ||
| * @param lineSeparator the newline separator sequence, or null to use the platform default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and #1944 interrelated. Ideally, this PR should go first.
| } | ||
|
|
||
| // while IME is active | ||
| static class Ime { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think can be private.
| * @since 26 | ||
| */ | ||
| // TODO depends on JDK-8370140 (line separator property), private for now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While a getText(...) method would be useful, I don't see an enhancement request that proposes it. I would make it more clear that this is not public API. If you want to leave the docs in place for a future enhancement that might provide such a public API, I recommend changing @since 26 to @since 99 (or similar).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct, this is not a public API (yet).
| first = false; | ||
| beg = start.offset(); | ||
| } else { | ||
| sb.append(lineSeparator); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, should lineSeparator be hardcoded as "\n" or should it be the line.separator property? We often use \n regardless of which platform we are on unless we are writing to a file or doing something else where it matters. This is more a question for PR #1944, so whatever you do here will very likely be modified when that enhancement is implemented. Unless you want to make this PR dependent on that one, choose something now (other than passing it in as a method parameter, since that seems an unlikely choice) and add a comment that it will need to be revisited.
|
I really want to test it on Linux - the IME there is quite fragile - and i will get back once i get my Linux box updated and running again. Should be done by the end of the week. |
kevinrushforth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Tested on Windows (in addition to macOS which I tested earlier).
I left a follow-up comment about your added TODOs. I'll reapprove if you make any changes.
| dy = f.snappedTopInset(); | ||
|
|
||
| p = f.rangeShape(start, end); | ||
| p = f.rangeShape(start, end); // TODO new api, no null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for filing the RFE. Since you aren't otherwise modifying this method in this PR, adding a random TODO like this seems like an unrelated change. Now if you meant to also add this comment to line 232 (the call to f.getUnderlineShape(start, end) that you added above), then I could see also adding a reminder here as well.
So I recommend either adding a similar comment on line 232, or removing the unrelated TODOs.
|
Thank you for review! |
kevinrushforth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to keep TODOs as they point to the areas that need improvement or further work.
Then how about adding another TODO in the newly added method? That one is actually related to this PR, and is another place that (once this is integrated) you will want to change when you implement JDK-8370902.
| dx = f.snappedLeftInset(); // TODO RTL? | ||
| dy = f.snappedTopInset(); | ||
|
|
||
| p = f.getUnderlineShape(start, end); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| p = f.getUnderlineShape(start, end); | |
| p = f.getUnderlineShape(start, end); // TODO new api |
|
I have tested couple of input methods including Japanese (Mozc) in different modes. In general the input method works and i was able to do the typing reasonably well but the editing sometimes leaves strange artifacts - especially when cancelling the suggestion - there is an underline text that was a raw input before suggestions and if you delete this text the underline stays but you can't navigate to that place as if there is no text but when window loses focus the raw input symbols re-appear in this place. Also whenever i am trying to commit a suggestion the following warning pops in the terminal where i started the application: (java:4993): IBUS-WARNING **: 15:31:22.791: ibus_input_context_post_process_key_event: Type 'h' is not supported. Not sure what it is about. |
|
Does it show the same artifacts with a regular TextArea? The video does not seem to show the composition popup when the backspace (?) key presses happen. On macOS, I noticed that Japanese IME works slightly different from Pinyin - you actually need to commit (or it thinks that it's still editing, I am not sure). Also, you can try enabling the Logging -> IME Monitor in the latest monkey tester and see what linux IME generates - on macOS, I could not do left arrow while in IME, and backspace simply removes the character and the dotted line underneath it. Could it be some bug in IME/Linux? The latest monkey tester: |
|
/integrate |
|
Going to push as commit 5d06943.
Your commit was automatically rebased without conflicts. |
|
@andy-goryachev-oracle Pushed as commit 5d06943. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |

Adds Input Method Editor (IME) support to
RichTextArea/CodeArea.Tested on macOS and Windows 11 with Japanese and Chinese (pinyin) input methods.
Please test this on Linux, even though there is no platform-specific code in this PR (should work the same way it does in
TextArea/TextField)For testing, one can use the updated Monkey Tester
https://github.com/andy-goryachev-oracle/MonkeyTest
(optionally enable IME events in stdout with Logging -> IME Monitor)
/reviewers 2
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1938/head:pull/1938$ git checkout pull/1938Update a local copy of the PR:
$ git checkout pull/1938$ git pull https://git.openjdk.org/jfx.git pull/1938/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1938View PR using the GUI difftool:
$ git pr show -t 1938Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1938.diff
Using Webrev
Link to Webrev Comment