LCL: Fix IME support for grids. Issue #36854, patch from Do-wan Kim.

git-svn-id: trunk@62954 -
This commit is contained in:
juha 2020-04-13 07:54:38 +00:00
parent 43787906ea
commit 9612688bb2

View File

@ -42,7 +42,7 @@ uses
LazFileUtils, DynamicArray, Maps, LazUTF8, LazUtf8Classes, Laz2_XMLCfg, LazFileUtils, DynamicArray, Maps, LazUTF8, LazUtf8Classes, Laz2_XMLCfg,
LazLoggerBase, LazUtilities, LCSVUtils, IntegerList LazLoggerBase, LazUtilities, LCSVUtils, IntegerList
{$ifdef WINDOWS} {$ifdef WINDOWS}
,messages ,messages, imm
{$endif} {$endif}
; ;
@ -1351,6 +1351,7 @@ type
protected protected
procedure IMEStartComposition(var Msg:TMessage); message WM_IME_STARTCOMPOSITION; procedure IMEStartComposition(var Msg:TMessage); message WM_IME_STARTCOMPOSITION;
procedure IMEComposition(var Msg:TMessage); message WM_IME_COMPOSITION; procedure IMEComposition(var Msg:TMessage); message WM_IME_COMPOSITION;
procedure IMEEndComposition(var Msg:TMessage); message WM_IME_ENDCOMPOSITION;
{$endif} {$endif}
end; end;
@ -9990,29 +9991,36 @@ begin
end; end;
{$ifdef WINDOWS} {$ifdef WINDOWS}
// editor focusing make bad on IME input.
procedure TCustomGrid.IMEStartComposition(var Msg: TMessage); procedure TCustomGrid.IMEStartComposition(var Msg: TMessage);
begin begin
// enable editor EditorSetValue;
SelectEditor; if EditingAllowed(FCol) and CanEditShow and (not FEditorShowing) and
EditorShow(True); (Editor<>nil) and (not Editor.Visible) and (not EditorLocked) then
if Editor<>nil then begin
Msg.Result:=SendMessage(Editor.Handle,Msg.msg,Msg.wParam,Msg.lParam); // prepare IME input on Editor
Editor.Visible:=True;
FEditorOldValue := GetCells(FCol,FRow);
EditorSelectAll;
FGridState := gsNormal;
Editor.Dispatch(Msg);
end;
end; end;
procedure TCustomGrid.IMEComposition(var Msg: TMessage); procedure TCustomGrid.IMEComposition(var Msg: TMessage);
var
wc : pWideChar;
s : string;
begin begin
wc := @Msg.wParamlo; if EditingAllowed(FCol) and CanEditShow and (not FEditorShowing) and
s := Ansistring(WideCharLenToString(wc,1)); (Editor<>nil) and (not Editor.Visible) and (not EditorLocked) then
// check valid mbcs Editor.Dispatch(Msg);
if (Length(s)>0) and (s[1]<>'?') then
Msg.wParamlo:=swap(pword(@s[1])^);
// send first mbcs to editor
if Editor<>nil then
Msg.Result:=SendMessage(Editor.Handle,Msg.msg,Msg.wParam,Msg.lParam);
end; end;
procedure TCustomGrid.IMEEndComposition(var Msg: TMessage);
begin
if EditingAllowed(FCol) and CanEditShow and (not FEditorShowing) and
(Editor<>nil) and (not Editor.Visible) and (not EditorLocked) then
Editor.Dispatch(Msg);
end;
{$endif} {$endif}
function TCustomGrid.ClearCols: Boolean; function TCustomGrid.ClearCols: Boolean;