From e6111ef577706fbb888ea2c155ef2512f5bb45cd Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Tue, 2 Jan 2018 19:06:52 +0100 Subject: [PATCH] Reactivate TSynHotKey again, after removing it accidentally in recent SynEdit update. Should fix a crashing preferences dialog. --- components/synedit/Source/SynEditMiscClasses.pas | 16 ++++++++++++++++ components/synedit/Source/SynEditReg.pas | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/components/synedit/Source/SynEditMiscClasses.pas b/components/synedit/Source/SynEditMiscClasses.pas index a75a17a2..09abaf92 100644 --- a/components/synedit/Source/SynEditMiscClasses.pas +++ b/components/synedit/Source/SynEditMiscClasses.pas @@ -372,6 +372,9 @@ type FInvalidKeys: THKInvalidKeys; FModifiers: THKModifiers; FPressedOnlyModifiers: Boolean; + FOnChange: TNotifyEvent; + FOnEnter: TNotifyEvent; + FOnExit: TNotifyEvent; procedure SetBorderStyle(const Value: TSynBorderStyle); procedure SetHotKey(const Value: TShortCut); procedure SetInvalidKeys(const Value: THKInvalidKeys); @@ -404,6 +407,9 @@ type property HotKey: TShortCut read FHotKey write SetHotKey default $0041; { Alt+A } property InvalidKeys: THKInvalidKeys read FInvalidKeys write SetInvalidKeys default [hcNone, hcShift]; 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; TSynEditSearchCustom = class(TComponent) @@ -1604,6 +1610,8 @@ begin end; Key := SavedKey; + if Assigned(FOnChange) then + FOnChange(Self); end; procedure TSynHotKey.KeyUp(var Key: Word; Shift: TShiftState); @@ -1652,6 +1660,10 @@ begin Canvas.Brush.Color := Color; InflateRect(r, -BorderWidth, -BorderWidth); Canvas.FillRect(r); + if Enabled then + Canvas.Font.Color := clWindowText + else + Canvas.Font.Color := clGrayText; TextRect(Canvas, r, BorderWidth + 1, BorderWidth + 1, Text); end; @@ -1716,6 +1728,8 @@ end; procedure TSynHotKey.WMKillFocus(var Msg: TWMKillFocus); begin DestroyCaret; + if Assigned(FOnExit) then + FOnExit(Self); end; procedure TSynHotKey.WMSetFocus(var Msg: TWMSetFocus); @@ -1724,6 +1738,8 @@ begin CreateCaret(Handle, 0, 1, -Canvas.Font.Height + 2); SetCaretPos(BorderWidth + 1 + TextWidth(Canvas, Text), BorderWidth + 1); ShowCaret(Handle); + if Assigned(FOnEnter) then + FOnEnter(Self); end; {$ENDIF} diff --git a/components/synedit/Source/SynEditReg.pas b/components/synedit/Source/SynEditReg.pas index f9357f0c..37713f46 100644 --- a/components/synedit/Source/SynEditReg.pas +++ b/components/synedit/Source/SynEditReg.pas @@ -255,7 +255,7 @@ begin TSynExporterTeX, TSynEditPythonBehaviour, TSynMultiSyn, TSynCompletionProposal, TSynAutoComplete, TSynMacroRecorder, TSynEditPrint, TSynEditPrintPreview, TSynAutoCorrect, - TSynEditSearch, TSynEditRegexSearch, TSynEditOptionsDialog, TSynURIOpener, + TSynEditSearch, TSynEditRegexSearch, TSynEditOptionsDialog, TSynURIOpener, TSynHotKey, TSynEditDocumentManager]); {$IFDEF SYN_COMPILER_4_UP} RegisterComponents(SYNS_ComponentsPage, [TSynHighlighterManager]);