View Issue Details

IDProjectCategoryView StatusLast Update
0036854LazarusLCLpublic2020-04-16 12:55
ReporterDo-wan Kim Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Product Version2.0.7 (SVN) 
Summary0036854: New grid IME support patch.
DescriptionOld Grid IME support breaks sometimes ago.
Focusing to cell editor cause IME Completion and loose IME composition state on cell editor.
It make break composition and cannot fine work with first IME keyboard input.

I make experimental method that have non-focusing cell editor.
But it's not perfect.

TagsNo tags attached.
Fixed in Revisionr62954
LazTarget-
WidgetsetWin32/Win64
Attached Files

Relationships

related to 0032101 new Memo,Edit Controls : lost input charactors when you enter Unicode via IME. On Windows 

Activities

Do-wan Kim

2020-03-31 15:27

reporter  

IME_friendly-grids.pas.patch (2,441 bytes)   
Index: lcl/grids.pas
===================================================================
--- lcl/grids.pas	(revision 62825)
+++ lcl/grids.pas	(working copy)
@@ -42,7 +42,7 @@
   LazFileUtils, DynamicArray, Maps, LazUTF8, LazUtf8Classes, Laz2_XMLCfg,
   LazLoggerBase, LazUtilities, LCSVUtils, IntegerList
 {$ifdef WINDOWS}
-  ,messages
+  ,messages, imm
 {$endif}
   ;
 
@@ -1351,6 +1351,7 @@
   protected
     procedure IMEStartComposition(var Msg:TMessage); message WM_IME_STARTCOMPOSITION;
     procedure IMEComposition(var Msg:TMessage); message WM_IME_COMPOSITION;
+    procedure IMEEndComposition(var Msg:TMessage); message WM_IME_ENDCOMPOSITION;
 {$endif}
   end;
 
@@ -7240,6 +7241,7 @@
     else
       FStringEditor.Alignment:=taLeftJustify;
   end;
+
   Editor.Visible:=True;
   if Focused and Editor.CanFocus then
     Editor.SetFocus;
@@ -9988,29 +9990,36 @@
 end;
 
 {$ifdef WINDOWS}
+// editor focusing make bad on IME input.
 procedure TCustomGrid.IMEStartComposition(var Msg: TMessage);
 begin
-  // enable editor
-  SelectEditor;
-  EditorShow(True);
-  if Editor<>nil then
-    Msg.Result:=SendMessage(Editor.Handle,Msg.msg,Msg.wParam,Msg.lParam);
+  EditorSetValue;
+  if EditingAllowed(FCol) and CanEditShow and (not FEditorShowing) and
+     (Editor<>nil) and (not Editor.Visible) and (not EditorLocked) then
+  begin
+    // prepare IME input on Editor
+    Editor.Visible:=True;
+    FEditorOldValue := GetCells(FCol,FRow);
+    EditorSelectAll;
+    FGridState := gsNormal;
+    Editor.Dispatch(Msg);
+  end;
 end;
 
 procedure TCustomGrid.IMEComposition(var Msg: TMessage);
-var
-  wc : pWideChar;
-  s : string;
 begin
-  wc := @Msg.wParamlo;
-  s := Ansistring(WideCharLenToString(wc,1));
-  // check valid mbcs
-  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);
+  if EditingAllowed(FCol) and CanEditShow and (not FEditorShowing) and
+     (Editor<>nil) and (not Editor.Visible) and (not EditorLocked) then
+    Editor.Dispatch(Msg);
 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}
 
 function TCustomGrid.ClearCols: Boolean;
IME_friendly-grids.pas.patch (2,441 bytes)   

Juha Manninen

2020-04-13 09:55

developer   ~0122108

Applied, thanks.

Issue History

Date Modified Username Field Change
2020-03-31 15:27 Do-wan Kim New Issue
2020-03-31 15:27 Do-wan Kim File Added: IME_friendly-grids.pas.patch
2020-03-31 21:26 Juha Manninen Relationship added related to 0032101
2020-04-12 23:46 Juha Manninen Assigned To => Juha Manninen
2020-04-12 23:46 Juha Manninen Status new => assigned
2020-04-13 09:55 Juha Manninen Status assigned => resolved
2020-04-13 09:55 Juha Manninen Resolution open => fixed
2020-04-13 09:55 Juha Manninen Fixed in Revision => r62954
2020-04-13 09:55 Juha Manninen LazTarget => -
2020-04-13 09:55 Juha Manninen Widgetset Win32/Win64 => Win32/Win64
2020-04-13 09:55 Juha Manninen Note Added: 0122108
2020-04-16 12:55 Do-wan Kim Status resolved => closed