From b92b6b18eededfee559fdbc3bb9cd047cedf983a Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Wed, 2 May 2018 14:01:47 +0200 Subject: [PATCH] fix #314 - Tab switching only works once --- src/ce_editor.lfm | 6 +++-- src/ce_editor.pas | 56 ++++++++++++++++++++++++++++------------------- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/ce_editor.lfm b/src/ce_editor.lfm index 28b58ed9..e6e08d17 100644 --- a/src/ce_editor.lfm +++ b/src/ce_editor.lfm @@ -6,6 +6,7 @@ inherited CEEditorWidget: TCEEditorWidget Caption = 'Source editor' ClientHeight = 434 ClientWidth = 465 + OnShortCut = FormShortCut inherited Back: TPanel Height = 434 Width = 465 @@ -13,13 +14,14 @@ inherited CEEditorWidget: TCEEditorWidget ClientWidth = 465 inherited Content: TPanel Height = 398 + Top = 36 Width = 465 ClientHeight = 398 ClientWidth = 465 object editorStatus: TStatusBar[0] Left = 0 - Height = 21 - Top = 375 + Height = 19 + Top = 377 Width = 465 BorderSpacing.Bottom = 2 Panels = < diff --git a/src/ce_editor.pas b/src/ce_editor.pas index c17db5c6..85d54b78 100644 --- a/src/ce_editor.pas +++ b/src/ce_editor.pas @@ -9,7 +9,7 @@ uses ComCtrls, SynEditHighlighter, ExtCtrls, Menus, SynMacroRecorder, dialogs, LazFileUtils, SynPluginSyncroEdit, SynEdit, SynHighlighterMulti, ce_dialogs, ce_widget, ce_interfaces, ce_synmemo, ce_dlang, ce_common, ce_dcd, ce_observer, - ce_sharedres, ce_controls, ce_writableComponent, ce_dsgncontrols; + ce_sharedres, ce_controls, ce_writableComponent, ce_dsgncontrols, LMessages; type @@ -93,6 +93,7 @@ type macRecorder: TSynMacroRecorder; editorStatus: TStatusBar; mnuEditor: TPopupMenu; + procedure FormShortCut(var Msg: TLMKey; var Handled: Boolean); procedure mnuedDdocTmpClick(Sender: TObject); procedure mnuedGotolineClick(Sender: TObject); procedure mnuedNextWarnClick(Sender: TObject); @@ -672,8 +673,6 @@ begin end; procedure TCEEditorWidget.memoKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); -var - sh: TShortCut; begin case Key of VK_CLEAR,VK_RETURN,VK_BACK : @@ -681,26 +680,6 @@ begin VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT: if Shift = [] then updateImperative; - else begin - // note: keys conflict can lead to a lose of focus, i.e shortcut - // to select next page cant be repeated. - sh := KeyToShortCut(Key, shift); - if sh = fOptions.fNextPage then - begin - pageControl.pageIndex:= (pageControl.pageIndex + 1) mod pageControl.pageCount; - end - else if sh = fOptions.fPrevPage then - begin - if pageControl.pageIndex - 1 < 0 then - pageControl.pageIndex:= pageControl.pageCount - 1 - else - pageControl.pageIndex:= pageControl.pageIndex - 1; - end - else if sh = fOptions.fMoveLeft then - pageControl.movePageLeft - else if sh = fOptions.fMoveRight then - pageControl.movePageRight; - end; end; if fKeyChanged then beginDelayedUpdate; @@ -992,6 +971,37 @@ begin fDoc.insertDdocTemplate; end; +procedure TCEEditorWidget.FormShortCut(var Msg: TLMKey; var Handled: Boolean); +var + sh: TShortCut; +begin + Handled := false; + sh := KeyToShortCut(Msg.CharCode, KeyDataToShiftState(Msg.KeyData)); + if sh = fOptions.fNextPage then + begin + pageControl.pageIndex:= (pageControl.pageIndex + 1) mod pageControl.pageCount; + Handled := true; + end + else if sh = fOptions.fPrevPage then + begin + if pageControl.pageIndex - 1 < 0 then + pageControl.pageIndex:= pageControl.pageCount - 1 + else + pageControl.pageIndex:= pageControl.pageIndex - 1; + Handled := true; + end + else if sh = fOptions.fMoveLeft then + begin + pageControl.movePageLeft; + Handled := true; + end + else if sh = fOptions.fMoveRight then + begin + pageControl.movePageRight; + Handled := true; + end; +end; + procedure TCEEditorWidget.mnuedGotolineClick(Sender: TObject); begin if fDoc.isNotNil then