SynEdit: win, IME Handler: added started/ended events

git-svn-id: trunk@48498 -
This commit is contained in:
martin 2015-03-24 23:35:29 +00:00
parent a2ec42e01e
commit 5fd753e72e

View File

@ -26,10 +26,15 @@ type
LazSynIme = class(TSynEditFriend) LazSynIme = class(TSynEditFriend)
private private
FInvalidateLinesMethod: TInvalidateLines; FInvalidateLinesMethod: TInvalidateLines;
FOnIMEEnd: TNotifyEvent;
FOnIMEStart: TNotifyEvent;
FIMEActive: Boolean;
protected protected
FInCompose: Boolean; FInCompose: Boolean;
procedure InvalidateLines(FirstLine, LastLine: integer); procedure InvalidateLines(FirstLine, LastLine: integer);
procedure StopIme(Success: Boolean); virtual; procedure StopIme(Success: Boolean); virtual;
procedure DoIMEStarted;
procedure DoIMEEnded;
public public
constructor Create(AOwner: TSynEditBase); reintroduce; constructor Create(AOwner: TSynEditBase); reintroduce;
procedure WMImeRequest(var Msg: TMessage); virtual; procedure WMImeRequest(var Msg: TMessage); virtual;
@ -39,6 +44,8 @@ type
procedure WMImeEndComposition(var Msg: TMessage); virtual; procedure WMImeEndComposition(var Msg: TMessage); virtual;
procedure FocusKilled; virtual; procedure FocusKilled; virtual;
property InvalidateLinesMethod : TInvalidateLines write FInvalidateLinesMethod; property InvalidateLinesMethod : TInvalidateLines write FInvalidateLinesMethod;
property OnIMEStart: TNotifyEvent read FOnIMEStart write FOnIMEStart;
property OnIMEEnd: TNotifyEvent read FOnIMEEnd write FOnIMEEnd;
end; end;
{ LazSynImeSimple } { LazSynImeSimple }
@ -127,6 +134,25 @@ begin
ImmNotifyIME(imc, NI_COMPOSITIONSTR, CPS_CANCEL, 0); ImmNotifyIME(imc, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
ImmReleaseContext(FriendEdit.Handle, imc); ImmReleaseContext(FriendEdit.Handle, imc);
end; end;
DoIMEEnded;
end;
procedure LazSynIme.DoIMEStarted;
begin
if FIMEActive then
exit;
FIMEActive := True;
if FOnIMEStart <> nil then
FOnIMEStart(FriendEdit);
end;
procedure LazSynIme.DoIMEEnded;
begin
if not FIMEActive then
exit;
FIMEActive := False;
if FOnIMEEnd <> nil then
FOnIMEEnd(FriendEdit);
end; end;
constructor LazSynIme.Create(AOwner: TSynEditBase); constructor LazSynIme.Create(AOwner: TSynEditBase);
@ -362,11 +388,13 @@ begin
end; end;
FInCompose := True; FInCompose := True;
FImeBlockSelection.StartLineBytePos := CaretObj.LineBytePos; FImeBlockSelection.StartLineBytePos := CaretObj.LineBytePos;
DoIMEStarted;
end; end;
procedure LazSynImeSimple.WMImeEndComposition(var Msg: TMessage); procedure LazSynImeSimple.WMImeEndComposition(var Msg: TMessage);
begin begin
FInCompose := False; FInCompose := False;
DoIMEEnded;
end; end;
procedure LazSynImeSimple.FocusKilled; procedure LazSynImeSimple.FocusKilled;
@ -845,6 +873,7 @@ begin
FImeBlockSelection.StartLineBytePos := CaretObj.LineBytePos; FImeBlockSelection.StartLineBytePos := CaretObj.LineBytePos;
FInCompose := True; FInCompose := True;
Msg.Result := 1; Msg.Result := 1;
DoIMEStarted;
end; end;
procedure LazSynImeFull.WMImeEndComposition(var Msg: TMessage); procedure LazSynImeFull.WMImeEndComposition(var Msg: TMessage);
@ -868,6 +897,7 @@ begin
FImeBlockSelection2.StartLineBytePos := CaretObj.LineBytePos; FImeBlockSelection2.StartLineBytePos := CaretObj.LineBytePos;
FInCompose := False; FInCompose := False;
Msg.Result := 1; Msg.Result := 1;
DoIMEEnded;
end; end;
procedure LazSynImeFull.FocusKilled; procedure LazSynImeFull.FocusKilled;