synedit: syncompletion: do not eat key

git-svn-id: trunk@27833 -
This commit is contained in:
mattias 2010-10-24 17:47:41 +00:00
parent b8344eeb9e
commit ff76cafd07

View File

@ -200,6 +200,7 @@ type
function GetClSelect: TColor; function GetClSelect: TColor;
function GetLongLineHintTime: Integer; function GetLongLineHintTime: Integer;
function GetLongLineHintType: TSynCompletionLongHintType; function GetLongLineHintType: TSynCompletionLongHintType;
function GetOnKeyDown: TKeyEvent;
function GetOnMeasureItem: TSynBaseCompletionMeasureItem; function GetOnMeasureItem: TSynBaseCompletionMeasureItem;
function GetOnPositionChanged: TNotifyEvent; function GetOnPositionChanged: TNotifyEvent;
procedure SetCaseSensitive(const AValue: boolean); procedure SetCaseSensitive(const AValue: boolean);
@ -218,6 +219,7 @@ type
procedure SetLongLineHintType(const AValue: TSynCompletionLongHintType); procedure SetLongLineHintType(const AValue: TSynCompletionLongHintType);
procedure SetNbLinesInWindow(const Value: Integer); procedure SetNbLinesInWindow(const Value: Integer);
procedure SetOnCancel(const Value: TNotifyEvent); procedure SetOnCancel(const Value: TNotifyEvent);
procedure SetOnKeyDown(const AValue: TKeyEvent);
procedure SetOnKeyPress(const Value: TKeyPressEvent); procedure SetOnKeyPress(const Value: TKeyPressEvent);
procedure SetOnMeasureItem(const AValue: TSynBaseCompletionMeasureItem); procedure SetOnMeasureItem(const AValue: TSynBaseCompletionMeasureItem);
procedure SetOnPositionChanged(const AValue: TNotifyEvent); procedure SetOnPositionChanged(const AValue: TNotifyEvent);
@ -245,6 +247,7 @@ type
procedure Deactivate; procedure Deactivate;
function IsActive: boolean; function IsActive: boolean;
function TheForm: TSynBaseCompletionForm; function TheForm: TSynBaseCompletionForm;
property OnKeyDown: TKeyEvent read GetOnKeyDown write SetOnKeyDown;
property OnUTF8KeyPress: TUTF8KeyPressEvent read GetOnUTF8KeyPress property OnUTF8KeyPress: TUTF8KeyPressEvent read GetOnUTF8KeyPress
write SetOnUTF8KeyPress; write SetOnUTF8KeyPress;
property OnKeyPress: TKeyPressEvent read GetOnKeyPress write SetOnKeyPress; property OnKeyPress: TKeyPressEvent read GetOnKeyPress write SetOnKeyPress;
@ -498,6 +501,8 @@ var
Handled: Boolean; Handled: Boolean;
begin begin
//debugln('TSynBaseCompletionForm.KeyDown A Key=',dbgs(Key)); //debugln('TSynBaseCompletionForm.KeyDown A Key=',dbgs(Key));
inherited KeyDown(Key,Shift);
if Key=VK_UNKNOWN then exit;
Handled:=true; Handled:=true;
case Key of case Key of
// added the VK_XXX codes to make it more readable / maintainable // added the VK_XXX codes to make it more readable / maintainable
@ -530,7 +535,7 @@ begin
VK_BACK: VK_BACK:
if (Shift = []) and (Length(CurrentString) > 0) then begin if (Shift = []) and (Length(CurrentString) > 0) then begin
if Assigned(OnKeyDelete) then OnKeyDelete(Self); if Assigned(OnKeyDelete) then OnKeyDelete(Self);
CurrentString := Copy(CurrentString, 1, Length(CurrentString) - 1); CurrentString := UTF8Copy(CurrentString, 1, UTF8Length(CurrentString) - 1);
end; end;
VK_TAB: VK_TAB:
begin begin
@ -555,10 +560,10 @@ end;
procedure TSynBaseCompletionForm.KeyPress(var Key: char); procedure TSynBaseCompletionForm.KeyPress(var Key: char);
begin begin
//debugln('TSynBaseCompletionForm.KeyPress A Key="',DbgStr(Key),'"'); debugln('TSynBaseCompletionForm.KeyPress A Key="',DbgStr(Key),'"');
if Assigned(OnKeyPress) then if Assigned(OnKeyPress) then
OnKeyPress(Self, Key); OnKeyPress(Self, Key);
//debugln('TSynBaseCompletionForm.KeyPress B Key="',DbgStr(Key),'"'); debugln('TSynBaseCompletionForm.KeyPress B Key="',DbgStr(Key),'"');
if Key=#0 then exit; if Key=#0 then exit;
case key of // case key of //
#33..'z': #33..'z':
@ -713,7 +718,7 @@ end;
procedure TSynBaseCompletionForm.UTF8KeyPress(var UTF8Key: TUTF8Char); procedure TSynBaseCompletionForm.UTF8KeyPress(var UTF8Key: TUTF8Char);
begin begin
//debugln('TSynBaseCompletionForm.UTF8KeyPress A UTF8Key="',DbgStr(UTF8Key),'" ',dbgsName(TObject(TMethod(OnUTF8KeyPress).Data))); debugln('TSynBaseCompletionForm.UTF8KeyPress A UTF8Key="',DbgStr(UTF8Key),'" ',dbgsName(TObject(TMethod(OnUTF8KeyPress).Data)));
if UTF8Key=#8 then if UTF8Key=#8 then
begin begin
// backspace // backspace
@ -743,7 +748,7 @@ begin
UTF8Key := ''; UTF8Key := '';
end; end;
end; end;
//debugln('TSynBaseCompletionForm.UTF8KeyPress END UTF8Key="',DbgStr(UTF8Key),'"'); debugln('TSynBaseCompletionForm.UTF8KeyPress END UTF8Key="',DbgStr(UTF8Key),'"');
end; end;
procedure TSynBaseCompletionForm.SetCurrentString(const Value: string); procedure TSynBaseCompletionForm.SetCurrentString(const Value: string);
@ -1076,6 +1081,11 @@ begin
form.OnCancel := Value; form.OnCancel := Value;
end; end;
procedure TSynBaseCompletion.SetOnKeyDown(const AValue: TKeyEvent);
begin
Form.OnKeyDown:=AValue;
end;
procedure TSynBaseCompletion.SetOnKeyPress(const Value: TKeyPressEvent); procedure TSynBaseCompletion.SetOnKeyPress(const Value: TKeyPressEvent);
begin begin
form.OnKeyPress := Value; form.OnKeyPress := Value;
@ -1123,6 +1133,11 @@ begin
Result := Form.LongLineHintType; Result := Form.LongLineHintType;
end; end;
function TSynBaseCompletion.GetOnKeyDown: TKeyEvent;
begin
Result:=Form.OnKeyDown;
end;
function TSynBaseCompletion.GetCaseSensitive: boolean; function TSynBaseCompletion.GetCaseSensitive: boolean;
begin begin
Result := Form.CaseSensitive; Result := Form.CaseSensitive;
@ -1385,8 +1400,6 @@ begin
// completion form is visible, but the synedit got a key // completion form is visible, but the synedit got a key
// -> redirect to form // -> redirect to form
Form.KeyDown(Key,Shift); Form.KeyDown(Key,Shift);
// eat it
Key:=VK_UNKNOWN;
//debugln('TSynCompletion.EditorKeyDown B ',dbgs(Key)); //debugln('TSynCompletion.EditorKeyDown B ',dbgs(Key));
end; end;