diff --git a/lcl/interfaces/cocoa/cocoafullcontroledit.pas b/lcl/interfaces/cocoa/cocoafullcontroledit.pas index 5be3b6d2c0..eb5b821786 100644 --- a/lcl/interfaces/cocoa/cocoafullcontroledit.pas +++ b/lcl/interfaces/cocoa/cocoafullcontroledit.pas @@ -11,6 +11,10 @@ uses LazUTF8, Graphics, CocoaGDIObjects, CocoaAll, CocoaPrivate, CocoaCustomControl, CocoaUtils; +const + IM_MESSAGE_WPARAM_GET_IME_HANDLER = 0; + IM_MESSAGE_WPARAM_GET_LW_HANDLER = 1; + type { ICocoaIMEControl } diff --git a/lcl/interfaces/cocoa/cocoawscommon.pas b/lcl/interfaces/cocoa/cocoawscommon.pas index 3d21228e65..b77e662191 100644 --- a/lcl/interfaces/cocoa/cocoawscommon.pas +++ b/lcl/interfaces/cocoa/cocoawscommon.pas @@ -1952,15 +1952,37 @@ end; { TCocoaWSCustomControl } +function SendIMCompostionMessage( + const control: TWinControl; const WParam: LclType.WPARAM ): PtrInt; +var + Mess : TLMessage; +begin + FillChar(Mess,SizeOf(Mess),0); + Mess.Msg:= LM_IM_COMPOSITION; + Mess.WParam:= WParam; + Result:= DeliverMessage( control, Mess ); +end; + // get IMEHandler by LM_IM_COMPOSITION message function getControlIMEHandler(const control: TWinControl): ICocoaIMEControl; var handle : PtrInt; begin - handle := SendSimpleMessage(control, LM_IM_COMPOSITION); + handle := SendIMCompostionMessage( control, IM_MESSAGE_WPARAM_GET_IME_HANDLER ); Result := TObject(handle) as ICocoaIMEControl; end; +// get Lookup Word Handler by LM_IM_COMPOSITION message +function getControlLWHandler(const control: TWinControl): ICocoaLookupWord; +var + handle: PtrInt; +begin + Result:= nil; + handle := SendIMCompostionMessage( control, IM_MESSAGE_WPARAM_GET_LW_HANDLER ); + if TObject(handle) is ICocoaLookupWord then + Result:= TObject(handle) as ICocoaLookupWord; +end; + class function TCocoaWSCustomControl.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLHandle; var @@ -1977,7 +1999,8 @@ begin // AWinControl is a Full Control Edit (such as SynEdit/ATSynEdit) ctrl := TCocoaFullControlEdit.alloc.lclInitWithCreateParams(AParams); lcl := TLCLFullControlEditCallback.Create(ctrl, AWinControl); - TCocoaFullControlEdit(ctrl).imeHandler := imeHandler; + TCocoaFullControlEdit(ctrl).imeHandler:= imeHandler; + TCocoaFullControlEdit(ctrl).lwHandler:= getControlLWHandler(AWinControl); TCocoaFullControlEdit(ctrl).unmarkText; end else