Skip to content
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

IME Candidate Window wrong behavior #15437

Open
evhenii-komar opened this issue Apr 18, 2024 · 3 comments
Open

IME Candidate Window wrong behavior #15437

evhenii-komar opened this issue Apr 18, 2024 · 3 comments
Labels

Comments

@evhenii-komar
Copy link

Describe the bug

The IME candidate window isn't closed if you click outside of it and in the same control it is used for. I develop custom control and found the only way to make the candidate window close is to put <AvaloniaAccessUnstablePrivateApis>true</AvaloniaAccessUnstablePrivateApis> into the <PropertyGroup> section of your project '.csproj' file and use this code inside of your Control to close it programmatically:

ITextInputMethodImpl inputMethod = (VisualRoot as ITextInputMethodRoot)?.InputMethod;
inputMethod.Reset();

But this way uses unstable private API so it isn't a confident solution.
I've checked the behavior in other frameworks like WinForms, and WPF, in Windows elements like Explorer, and Notepad, and browsers like Chrome and Edge. All of them close the IME Candidate Window if you click outside of the candidate window even if you click the focused element the candidate window was opened for.

To Reproduce

  • Compile and run the BasicMvvmSample.
  • Put the focus on the TextBox and switch to the Japanese Hiragana language.
  • Type something. The IME Candidate Window will have appeared.
  • Click outside of the IME Candidate Window but on the same TextBox surface.

The IME Candidate Window wasn't hidden.

Expected behavior

The IME Candidate Window is hidden.

Avalonia version

11.0.10

OS

Windows

Additional context

No response

@Gillibald
Copy link
Contributor

Ime should be reset after focus change/loss

@Gillibald
Copy link
Contributor

Gillibald commented Apr 18, 2024

We might be able to change this by introducing a way to cancel current composition. What happens with the current composition. Is it committed as is or discarded?

@evhenii-komar
Copy link
Author

evhenii-komar commented Apr 18, 2024

Ime should be reset after focus change/loss

Yes, it is one of the reasons that should reset it but not the only expected. In checked frameworks, Windows elements, and browsers I mentioned above the focus loss isn't the only reason to reset Ime. The clicking anywhere outside the candidate window even on the surface of the focused control is the reason too. It can be checked by opening any element of Windows or browser. But, if it is the Avalonia behavior I would like to have a legal way to close it programmatically for my control.

We might be able to change this by introducing a way to cancel current composition. What happens with the current composition. Is it committed as is or discarded?

If you mean what will happen if I use this code to close the composition:

            ITextInputMethodImpl inputMethod = (VisualRoot as ITextInputMethodRoot)?.InputMethod;
            inputMethod?.Reset();

then it is discarded but I can avoid this by saving the last preedit text. I just need the candidate window to be hidden automatically if the user clicks outside of it. In this case, the text shouldn't be discarded. In WPF, WinForms etc. it isn't discarded. Or, the API to close it would be an option too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants