ATSynEdit
ATSynEdit copied to clipboard
New workaround / How to set Emoji popup position #238
Follow up an #238
I believe I found a workaround to fix it.... https://github.com/User4martin/lazarus/commit/0e05c525dc8e0e28e5a07d79604b0a367710ec00
The first time the emoji IME opens it takes the position given by IMR_QUERYCHARPOSITION (or (not tested) possibly set by ImmSetCompositionWindow).
But then it sticks there. Until the Windows lost focus...
So make it loose focus.
This could be done in WM_IME_ENDCOMPOSITION But that is only called if a smiley was inputed. If the IME closed without selecting a smiley then this is not called.
So, I record when IMR_QUERYCHARPOSITION is called. While the IME is open the editor does not get keystrokes (or the IME should know when it started composing). After that, the next time the caret changes, focus is triggered.
Works in TSynEdit for me. Hope it helps you
I am not good at this topic,.... so I can only get the ready patch. Tested patch...
@rasberryrabbit Maybe this Win32 IME issue can be handled by you
I tried but IMR_QUERYCHARPOSITION doesn't be called. I got WM_IME_ENDCOMPOSITION only.
It cannot fire messages on popup.
SetFocus(0);
SetFocus(Editor.Handle);
is some tweak to make right position for popup.
But I don't know good place for code.
Does ATSynEdit draw the composition (while it is happening) itself? I think, that is (but have to check) handling GCS_COMPSTR.
If an app does not do that, Windows does paint a small rectangle with the preview overlaying the editor. In that case the trick does not work (or not in the given way)
No, ATsynedit doesn't draw any special stuff - current IME code is only passes unicode chars to TextInsertAtCarets() etc.
Emoji window appear before IME composition handler. IME composition handler doesn't do at all. Emoji window may need some setting for window position. SetFocus tweak may update position for it.
Couple of notes. I tested a lot of apps (notepad++, LibreOffice, Chrome) they all have the issue that the position does not update for the smiley IME. (and sometimes the paste older clipboard version) ....
The IME sticks to where it opened the first time. And that first time is correct, if you do call ImmSetCompositionWindow or similar whenever needed / on caret change)
If you can get some indication, that the IME was open (which is what IMR_QUERYCHARPOSITION does for me), and if you can then make sure you tweaked the focus before the next time the IME is triggered, => that should help)
Note: not tested. I assume the IME keeps some invisible window open? there are like status win, and stuff that I still try to figure. Maybe sending a close to them, instead of kill focus??? But that is another lengthy testing session.
Also: I do not know if this has a negative impact on screen readers... If so, => another option.... sigh
@rasberryrabbit I don’t know what to fix here. How to fix here . Have you any idea how to use Martin’s advice? Or we should close this?
I can't get any IME message on pre-openning emoji window. There is no way to set emoji window position.
After emoji inserting, there is a IMR_QUERYCHARPOSITION message but no effect on emoji window.
I can't find document how to set emoji popup window.
Below is the SynEdit commit that iirc fixes it: If there was a previous IME at any point, then SetFocus(0) to lose focus, and refocus. (FriendEdit is the current edit)
I try updating code.
This seems to be the best I can do.
Thanks but if it is only partial fix (if it needs the previous IME dialog show) , it is not ok…. I am not sure…
It is hard to fix.
It needs pre-IME input condition for Emoji popup position.
There is no way to fix non-microsoft windows input control.