mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Enhance SynEdit's TSynHotKey:
* Add events OnChange, OnEnter and OnExit * Use gray text when disabled
This commit is contained in:
@ -328,6 +328,9 @@ type
|
|||||||
FInvalidKeys: THKInvalidKeys;
|
FInvalidKeys: THKInvalidKeys;
|
||||||
FModifiers: THKModifiers;
|
FModifiers: THKModifiers;
|
||||||
FPressedOnlyModifiers: Boolean;
|
FPressedOnlyModifiers: Boolean;
|
||||||
|
FOnChange: TNotifyEvent;
|
||||||
|
FOnEnter: TNotifyEvent;
|
||||||
|
FOnExit: TNotifyEvent;
|
||||||
procedure SetBorderStyle(const Value: TSynBorderStyle);
|
procedure SetBorderStyle(const Value: TSynBorderStyle);
|
||||||
procedure SetHotKey(const Value: TShortCut);
|
procedure SetHotKey(const Value: TShortCut);
|
||||||
procedure SetInvalidKeys(const Value: THKInvalidKeys);
|
procedure SetInvalidKeys(const Value: THKInvalidKeys);
|
||||||
@ -360,6 +363,9 @@ type
|
|||||||
property HotKey: TShortCut read FHotKey write SetHotKey default $0041; { Alt+A }
|
property HotKey: TShortCut read FHotKey write SetHotKey default $0041; { Alt+A }
|
||||||
property InvalidKeys: THKInvalidKeys read FInvalidKeys write SetInvalidKeys default [hcNone, hcShift];
|
property InvalidKeys: THKInvalidKeys read FInvalidKeys write SetInvalidKeys default [hcNone, hcShift];
|
||||||
property Modifiers: THKModifiers read FModifiers write SetModifiers default [hkAlt];
|
property Modifiers: THKModifiers read FModifiers write SetModifiers default [hkAlt];
|
||||||
|
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
||||||
|
property OnEnter: TNotifyEvent read FOnEnter write FOnEnter;
|
||||||
|
property OnExit: TNotifyEvent read FOnExit write FOnExit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TSynEditSearchCustom = class(TComponent)
|
TSynEditSearchCustom = class(TComponent)
|
||||||
@ -1381,6 +1387,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
Key := SavedKey;
|
Key := SavedKey;
|
||||||
|
if Assigned(FOnChange) then
|
||||||
|
FOnChange(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSynHotKey.KeyUp(var Key: Word; Shift: TShiftState);
|
procedure TSynHotKey.KeyUp(var Key: Word; Shift: TShiftState);
|
||||||
@ -1429,6 +1437,10 @@ begin
|
|||||||
Canvas.Brush.Color := Color;
|
Canvas.Brush.Color := Color;
|
||||||
InflateRect(r, -BorderWidth, -BorderWidth);
|
InflateRect(r, -BorderWidth, -BorderWidth);
|
||||||
Canvas.FillRect(r);
|
Canvas.FillRect(r);
|
||||||
|
if Enabled then
|
||||||
|
Canvas.Font.Color := clWindowText
|
||||||
|
else
|
||||||
|
Canvas.Font.Color := clGrayText;
|
||||||
TextRect(Canvas, r, BorderWidth + 1, BorderWidth + 1, Text);
|
TextRect(Canvas, r, BorderWidth + 1, BorderWidth + 1, Text);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1493,6 +1505,8 @@ end;
|
|||||||
procedure TSynHotKey.WMKillFocus(var Msg: TWMKillFocus);
|
procedure TSynHotKey.WMKillFocus(var Msg: TWMKillFocus);
|
||||||
begin
|
begin
|
||||||
DestroyCaret;
|
DestroyCaret;
|
||||||
|
if Assigned(FOnExit) then
|
||||||
|
FOnExit(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSynHotKey.WMSetFocus(var Msg: TWMSetFocus);
|
procedure TSynHotKey.WMSetFocus(var Msg: TWMSetFocus);
|
||||||
@ -1501,6 +1515,8 @@ begin
|
|||||||
CreateCaret(Handle, 0, 1, -Canvas.Font.Height + 2);
|
CreateCaret(Handle, 0, 1, -Canvas.Font.Height + 2);
|
||||||
SetCaretPos(BorderWidth + 1 + TextWidth(Canvas, Text), BorderWidth + 1);
|
SetCaretPos(BorderWidth + 1 + TextWidth(Canvas, Text), BorderWidth + 1);
|
||||||
ShowCaret(Handle);
|
ShowCaret(Handle);
|
||||||
|
if Assigned(FOnEnter) then
|
||||||
|
FOnEnter(Self);
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user