Can you report this on the bug tracker (with the info from your last post), please.
The problem seems to be caused by incomplete handling of IME composition messages, possibly WM_IME_COMPOSITION or WM_IME_NOTIFY,
Do you know which ones?
Needs to be double checked, but normally TEdit forwards most messages to the DefaultWindowProc. Then it would all be handled by Windows itself. But maybe its the reverse. Something isn't filtered out and reaches the LCL KeyDown/Up.
But I have not checked that. (Too busy right now)
And, does the Source-editor in the IDE (SynEdit) handle them? (so maybe this can be used as reference.
There is a setting in the option (affecting the source editor only), would be good to know for the setting on/off.
Menu: Tools > Options
Page: Editor > General > Miscellaneous
Checkbox in the top section: "IME handled by System"
Hi Martin, thank you for your helpful guidance earlier — especially the suggestions about message handling and testing with SynEdit.
I've done additional testing and would like to summarize the updated results:
The issue (text being overwritten after IME candidate selection via arrow keys + Enter) occurs in:
TEdit
TComboBox
TDBGrid (when editing a cell)
The Object Inspector inside the Lazarus IDE
The issue does not occur in:
TMemo
SynEdit (tested via the IDE’s Source Editor)
I also tested the SynEdit option “IME handled by System” (under Tools > Options > Editor > General > Miscellaneous), and it makes no difference — the behavior is consistent either way.
Additionally, setting AutoSelect := False on TEdit does prevent the overwrite issue.
I tested both with and without manifest and UTF-8 codepage enabled. These settings do not affect the outcome.
I have now confirmed that the issue still exists in Lazarus 4.0, so it's not limited to version 2.2.6.
At the moment, I don’t have time to study the Lazarus source code, so I’m only reporting what I’ve observed during testing. I’ll report this to the bug tracker as you suggested. Thanks again for pointing me in the right direction.