mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 17:39:20 +02:00
Cocoa: LookupWord handler enabled in TCocoaWSCustomControl.CreateHandle()
This commit is contained in:
parent
cfbd95b451
commit
0715fcb1c7
@ -11,6 +11,10 @@ uses
|
|||||||
LazUTF8, Graphics, CocoaGDIObjects,
|
LazUTF8, Graphics, CocoaGDIObjects,
|
||||||
CocoaAll, CocoaPrivate, CocoaCustomControl, CocoaUtils;
|
CocoaAll, CocoaPrivate, CocoaCustomControl, CocoaUtils;
|
||||||
|
|
||||||
|
const
|
||||||
|
IM_MESSAGE_WPARAM_GET_IME_HANDLER = 0;
|
||||||
|
IM_MESSAGE_WPARAM_GET_LW_HANDLER = 1;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ ICocoaIMEControl }
|
{ ICocoaIMEControl }
|
||||||
|
|
||||||
|
@ -1952,15 +1952,37 @@ end;
|
|||||||
|
|
||||||
{ TCocoaWSCustomControl }
|
{ 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
|
// get IMEHandler by LM_IM_COMPOSITION message
|
||||||
function getControlIMEHandler(const control: TWinControl): ICocoaIMEControl;
|
function getControlIMEHandler(const control: TWinControl): ICocoaIMEControl;
|
||||||
var
|
var
|
||||||
handle : PtrInt;
|
handle : PtrInt;
|
||||||
begin
|
begin
|
||||||
handle := SendSimpleMessage(control, LM_IM_COMPOSITION);
|
handle := SendIMCompostionMessage( control, IM_MESSAGE_WPARAM_GET_IME_HANDLER );
|
||||||
Result := TObject(handle) as ICocoaIMEControl;
|
Result := TObject(handle) as ICocoaIMEControl;
|
||||||
end;
|
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;
|
class function TCocoaWSCustomControl.CreateHandle(const AWinControl: TWinControl;
|
||||||
const AParams: TCreateParams): TLCLHandle;
|
const AParams: TCreateParams): TLCLHandle;
|
||||||
var
|
var
|
||||||
@ -1977,7 +1999,8 @@ begin
|
|||||||
// AWinControl is a Full Control Edit (such as SynEdit/ATSynEdit)
|
// AWinControl is a Full Control Edit (such as SynEdit/ATSynEdit)
|
||||||
ctrl := TCocoaFullControlEdit.alloc.lclInitWithCreateParams(AParams);
|
ctrl := TCocoaFullControlEdit.alloc.lclInitWithCreateParams(AParams);
|
||||||
lcl := TLCLFullControlEditCallback.Create(ctrl, AWinControl);
|
lcl := TLCLFullControlEditCallback.Create(ctrl, AWinControl);
|
||||||
TCocoaFullControlEdit(ctrl).imeHandler := imeHandler;
|
TCocoaFullControlEdit(ctrl).imeHandler:= imeHandler;
|
||||||
|
TCocoaFullControlEdit(ctrl).lwHandler:= getControlLWHandler(AWinControl);
|
||||||
TCocoaFullControlEdit(ctrl).unmarkText;
|
TCocoaFullControlEdit(ctrl).unmarkText;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user