diff --git a/Source/forms/simba.main.lfm b/Source/forms/simba.main.lfm index 829aa4254..1981f66e3 100644 --- a/Source/forms/simba.main.lfm +++ b/Source/forms/simba.main.lfm @@ -1,16 +1,14 @@ object SimbaForm: TSimbaForm - Left = 3003 + Left = 4007 Height = 539 - Top = 557 + Top = 508 Width = 1015 Caption = 'Simba' - ClientHeight = 0 - ClientWidth = 0 + ClientHeight = 539 + ClientWidth = 1015 DesignTimePPI = 120 - KeyPreview = True OnClose = FormClose OnDestroy = FormDestroy - OnKeyDown = FormKeyDown OnWindowStateChange = FormWindowStateChange Position = poScreenCenter LCLVersion = '3.0.0.2' diff --git a/Source/forms/simba.main.pas b/Source/forms/simba.main.pas index f663c29a9..b982d20dd 100644 --- a/Source/forms/simba.main.pas +++ b/Source/forms/simba.main.pas @@ -169,7 +169,6 @@ TSimbaForm = class(TForm) procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); procedure FormDestroy(Sender: TObject); - procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure FormWindowStateChange(Sender: TObject); procedure ImagesGetWidthForPPI(Sender: TCustomImageList; AImageWidth, APPI: Integer; var AResultWidth: Integer); procedure MainMenuMeasureItem(Sender: TObject; ACanvas: TCanvas; var AWidth, AHeight: Integer); @@ -239,6 +238,9 @@ TSimbaForm = class(TForm) procedure HandleException(Sender: TObject; E: Exception); procedure HandleFormCreated(Sender: TObject; Form: TCustomForm); + // Handle main menu shortcuts if editor is focused + procedure DoApplicationKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); + procedure DoTabLoaded(Sender: TObject); procedure SetCustomFontSize(Value: Integer); @@ -270,7 +272,7 @@ implementation simba.dockinghelpers, simba.nativeinterface, simba.scriptformatter, simba.theme, simba.scriptbackup, simba.backupsform, simba.threading, - simba.downloadsimbaform; + simba.downloadsimbaform, simba.editor; procedure TSimbaForm.HandleException(Sender: TObject; E: Exception); @@ -547,6 +549,7 @@ procedure TSimbaForm.Setup; Application.CaptureExceptions := True; Application.OnException := @Self.HandleException; + Application.AddOnKeyDownBeforeHandler(@DoApplicationKeyDown); Screen.AddHandlerFormAdded(@Self.HandleFormCreated, True); @@ -589,20 +592,23 @@ procedure TSimbaForm.FormDestroy(Sender: TObject); SimbaSettings.Save(); end; -procedure TSimbaForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); +procedure TSimbaForm.DoApplicationKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); var Msg: TLMKey; begin - Msg := Default(TLMKey); - Msg.CharCode := Key; - if (ssAlt in Shift) then - Msg.KeyData := MK_ALT; - - if MainMenuFile.IsShortcut(Msg) or MainMenuView.IsShortcut(Msg) or - MainMenuEdit.IsShortcut(Msg) or MainMenuScript.IsShortcut(Msg) or - MainMenuTools.IsShortcut(Msg) or MainMenuHelp.IsShortcut(Msg) or - MainMenuSearch.IsShortcut(Msg) then - Key := 0; + if (Screen.ActiveControl is TSimbaEditor) then + begin + Msg := Default(TLMKey); + Msg.CharCode := Key; + if (ssAlt in Shift) then + Msg.KeyData := MK_ALT; + + if MainMenuFile.IsShortcut(Msg) or MainMenuView.IsShortcut(Msg) or + MainMenuEdit.IsShortcut(Msg) or MainMenuScript.IsShortcut(Msg) or + MainMenuTools.IsShortcut(Msg) or MainMenuHelp.IsShortcut(Msg) or + MainMenuSearch.IsShortcut(Msg) then + Key := 0; + end; end; procedure TSimbaForm.FormWindowStateChange(Sender: TObject);