IDE: replaced key grabbing with new TShortCutGrabBox and TShortCutDialog

git-svn-id: trunk@15887 -
This commit is contained in:
mattias 2008-07-27 10:23:21 +00:00
parent a562835ecc
commit 7d530305f0
10 changed files with 979 additions and 1246 deletions

3
.gitattributes vendored
View File

@ -2157,6 +2157,9 @@ ide/keymapping.pp svneol=native#text/pascal
ide/keymapschemedlg.lfm svneol=native#text/plain ide/keymapschemedlg.lfm svneol=native#text/plain
ide/keymapschemedlg.lrs svneol=native#text/pascal ide/keymapschemedlg.lrs svneol=native#text/pascal
ide/keymapschemedlg.pas svneol=native#text/pascal ide/keymapschemedlg.pas svneol=native#text/pascal
ide/keymapshortcutdlg.lfm svneol=native#text/plain
ide/keymapshortcutdlg.lrs svneol=native#text/plain
ide/keymapshortcutdlg.pas svneol=native#text/plain
ide/lazarus.lpi svneol=native#text/plain ide/lazarus.lpi svneol=native#text/plain
ide/lazarus.pp svneol=native#text/pascal ide/lazarus.pp svneol=native#text/pascal
ide/lazarus.rc svneol=native#text/plain ide/lazarus.rc svneol=native#text/plain

View File

@ -52,7 +52,7 @@ uses
IDECommands, IDEWindowIntf, SrcEditorIntf, IDECommands, IDEWindowIntf, SrcEditorIntf,
// IDE // IDE
LazarusIDEStrConsts, IDEOptionDefs, IDEProcs, InputHistory, KeyMapping, LazarusIDEStrConsts, IDEOptionDefs, IDEProcs, InputHistory, KeyMapping,
KeymapSchemeDlg, LazConf; KeymapSchemeDlg, KeyMapShortCutDlg, LazConf;
type type
TPreviewEditor = TSynEdit; TPreviewEditor = TSynEdit;
@ -2854,7 +2854,7 @@ procedure TEditorOptionsForm.KeyMappingFindKeyButtonClick(Sender: TObject);
var var
KeyFilter: TIDEShortCut; KeyFilter: TIDEShortCut;
begin begin
if ShowKeyMappingGrabForm(EditingKeyMap,KeyFilter)<>mrOK then exit; if ShowKeyMappingGrabForm(KeyFilter)<>mrOK then exit;
//debugln(['TEditorOptionsForm.KeyMappingFindKeyButtonClick ',KeyAndShiftStateToEditorKeyString(KeyFilter)]); //debugln(['TEditorOptionsForm.KeyMappingFindKeyButtonClick ',KeyAndShiftStateToEditorKeyString(KeyFilter)]);
KeyMapKeyFilter:=KeyFilter; KeyMapKeyFilter:=KeyFilter;
FillKeyMappingTreeView; FillKeyMappingTreeView;
@ -3978,7 +3978,6 @@ end;
procedure TEditorOptionsForm.OkButtonClick(Sender: TObject); procedure TEditorOptionsForm.OkButtonClick(Sender: TObject);
var var
SynOptions: TSynEditorOptions;
i: Integer; i: Integer;
begin begin
IDEDialogLayoutList.SaveLayout(Self); IDEDialogLayoutList.SaveLayout(Self);

View File

@ -3,8 +3,6 @@ object ExternalToolOptionDlg: TExternalToolOptionDlg
Height = 501 Height = 501
Top = 210 Top = 210
Width = 661 Width = 661
HorzScrollBar.Page = 660
VertScrollBar.Page = 500
ActiveControl = TitleEdit ActiveControl = TitleEdit
Caption = 'ExternalToolOptionDlg' Caption = 'ExternalToolOptionDlg'
ClientHeight = 501 ClientHeight = 501
@ -14,7 +12,6 @@ object ExternalToolOptionDlg: TExternalToolOptionDlg
KeyPreview = True KeyPreview = True
OnCreate = FormCreate OnCreate = FormCreate
OnDestroy = FormDestroy OnDestroy = FormDestroy
OnKeyUp = FormKeyUp
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '0.9.25' LCLVersion = '0.9.25'
object TitleLabel: TLabel object TitleLabel: TLabel
@ -194,92 +191,15 @@ object ExternalToolOptionDlg: TExternalToolOptionDlg
AnchorSideRight.Control = OptionsGroupBox AnchorSideRight.Control = OptionsGroupBox
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 6 Left = 6
Height = 49 Height = 25
Top = 220 Top = 220
Width = 649 Width = 649
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoSize = True AutoSize = True
BorderSpacing.Top = 6 BorderSpacing.Top = 6
Caption = 'KeyGroupBox' Caption = 'KeyGroupBox'
ClientHeight = 30 Constraints.MinHeight = 25
ClientWidth = 645
TabOrder = 6 TabOrder = 6
object KeyCtrlCheckBox: TCheckBox
AnchorSideLeft.Control = KeyGroupBox
AnchorSideTop.Control = KeyGroupBox
AnchorSideBottom.Control = KeyGroupBox
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 22
Top = 2
Width = 131
Anchors = [akTop, akLeft, akBottom]
BorderSpacing.Left = 6
BorderSpacing.Top = 2
BorderSpacing.Bottom = 6
Caption = 'KeyCtrlCheckBox'
TabOrder = 0
end
object KeyAltCheckBox: TCheckBox
AnchorSideLeft.Control = KeyCtrlCheckBox
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = KeyCtrlCheckBox
Left = 143
Height = 22
Top = 2
Width = 126
BorderSpacing.Left = 6
Caption = 'KeyAltCheckBox'
TabOrder = 1
end
object KeyShiftCheckBox: TCheckBox
AnchorSideLeft.Control = KeyAltCheckBox
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = KeyCtrlCheckBox
Left = 275
Height = 22
Top = 2
Width = 138
BorderSpacing.Left = 6
Caption = 'KeyShiftCheckBox'
TabOrder = 2
end
object KeyComboBox: TComboBox
AnchorSideLeft.Control = KeyShiftCheckBox
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = KeyCtrlCheckBox
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = KeyGrabButton
Left = 419
Height = 29
Top = -1
Width = 106
Anchors = [akTop, akLeft, akRight]
AutoCompleteText = [cbactEndOfLineComplete, cbactSearchAscending]
BorderSpacing.Left = 6
BorderSpacing.Right = 6
MaxLength = 0
TabOrder = 3
Text = 'KeyComboBox'
end
object KeyGrabButton: TButton
AnchorSideTop.Control = KeyCtrlCheckBox
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = KeyGroupBox
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 531
Height = 29
Top = -2
Width = 108
Anchors = [akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'KeyGrabButton'
OnClick = KeyGrabButtonClick
TabOrder = 4
end
end end
object MacrosGroupbox: TGroupBox object MacrosGroupbox: TGroupBox
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
@ -289,13 +209,13 @@ object ExternalToolOptionDlg: TExternalToolOptionDlg
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = BtnPanel AnchorSideBottom.Control = BtnPanel
Left = 6 Left = 6
Height = 172 Height = 196
Top = 275 Top = 251
Width = 649 Width = 649
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'MacrosGroupbox' Caption = 'MacrosGroupbox'
ClientHeight = 153 ClientHeight = 177
ClientWidth = 645 ClientWidth = 645
TabOrder = 7 TabOrder = 7
object MacrosListbox: TListBox object MacrosListbox: TListBox
@ -305,7 +225,7 @@ object ExternalToolOptionDlg: TExternalToolOptionDlg
AnchorSideBottom.Control = MacrosGroupbox AnchorSideBottom.Control = MacrosGroupbox
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 6 Left = 6
Height = 145 Height = 169
Top = 2 Top = 2
Width = 490 Width = 490
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]

View File

@ -2,136 +2,107 @@
LazarusResources.Add('TExternalToolOptionDlg','FORMDATA',[ LazarusResources.Add('TExternalToolOptionDlg','FORMDATA',[
'TPF0'#22'TExternalToolOptionDlg'#21'ExternalToolOptionDlg'#4'Left'#3'\'#1#6 'TPF0'#22'TExternalToolOptionDlg'#21'ExternalToolOptionDlg'#4'Left'#3'\'#1#6
+'Height'#3#245#1#3'Top'#3#210#0#5'Width'#3#149#2#18'HorzScrollBar.Page'#3#148 +'Height'#3#245#1#3'Top'#3#210#0#5'Width'#3#149#2#13'ActiveControl'#7#9'Title'
+#2#18'VertScrollBar.Page'#3#244#1#13'ActiveControl'#7#9'TitleEdit'#7'Caption' +'Edit'#7'Caption'#6#21'ExternalToolOptionDlg'#12'ClientHeight'#3#245#1#11'Cl'
+#6#21'ExternalToolOptionDlg'#12'ClientHeight'#3#245#1#11'ClientWidth'#3#149#2 +'ientWidth'#3#149#2#21'Constraints.MinHeight'#3'^'#1#20'Constraints.MinWidth'
+#21'Constraints.MinHeight'#3'^'#1#20'Constraints.MinWidth'#3'^'#1#10'KeyPrev' +#3'^'#1#10'KeyPreview'#9#8'OnCreate'#7#10'FormCreate'#9'OnDestroy'#7#11'Form'
+'iew'#9#8'OnCreate'#7#10'FormCreate'#9'OnDestroy'#7#11'FormDestroy'#7'OnKeyU' +'Destroy'#8'Position'#7#14'poScreenCenter'#10'LCLVersion'#6#6'0.9.25'#0#6'TL'
+'p'#7#9'FormKeyUp'#8'Position'#7#14'poScreenCenter'#10'LCLVersion'#6#6'0.9.2' +'abel'#10'TitleLabel'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop'
+'5'#0#6'TLabel'#10'TitleLabel'#22'AnchorSideLeft.Control'#7#5'Owner'#21'Anch' +'.Control'#7#9'TitleEdit'#18'AnchorSideTop.Side'#7#9'asrCenter'#4'Left'#2#6#6
+'orSideTop.Control'#7#9'TitleEdit'#18'AnchorSideTop.Side'#7#9'asrCenter'#4'L' +'Height'#2#20#3'Top'#2#7#5'Width'#2'='#18'BorderSpacing.Left'#2#6#7'Caption'
+'eft'#2#6#6'Height'#2#20#3'Top'#2#7#5'Width'#2'='#18'BorderSpacing.Left'#2#6 +#6#10'TitleLabel'#11'ParentColor'#8#0#0#6'TLabel'#13'FilenameLabel'#22'Ancho'
+#7'Caption'#6#10'TitleLabel'#11'ParentColor'#8#0#0#6'TLabel'#13'FilenameLabe' +'rSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7#12'FilenameEdit'
+'l'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7#12'Fil' +#18'AnchorSideTop.Side'#7#9'asrCenter'#4'Left'#2#6#6'Height'#2#20#3'Top'#2'$'
+'enameEdit'#18'AnchorSideTop.Side'#7#9'asrCenter'#4'Left'#2#6#6'Height'#2#20 +#5'Width'#2'\'#18'BorderSpacing.Left'#2#6#7'Caption'#6#13'FilenameLabel'#11
+#3'Top'#2'$'#5'Width'#2'\'#18'BorderSpacing.Left'#2#6#7'Caption'#6#13'Filena' +'ParentColor'#8#0#0#6'TLabel'#15'ParametersLabel'#22'AnchorSideLeft.Control'
+'meLabel'#11'ParentColor'#8#0#0#6'TLabel'#15'ParametersLabel'#22'AnchorSideL' +#7#5'Owner'#21'AnchorSideTop.Control'#7#14'ParametersEdit'#18'AnchorSideTop.'
+'eft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7#14'ParametersEdit'#18'A' +'Side'#7#9'asrCenter'#4'Left'#2#6#6'Height'#2#20#3'Top'#2'A'#5'Width'#2'm'#18
+'nchorSideTop.Side'#7#9'asrCenter'#4'Left'#2#6#6'Height'#2#20#3'Top'#2'A'#5 +'BorderSpacing.Left'#2#6#7'Caption'#6#15'ParametersLabel'#11'ParentColor'#8#0
+'Width'#2'm'#18'BorderSpacing.Left'#2#6#7'Caption'#6#15'ParametersLabel'#11 +#0#6'TLabel'#15'WorkingDirLabel'#22'AnchorSideLeft.Control'#7#5'Owner'#21'An'
+'ParentColor'#8#0#0#6'TLabel'#15'WorkingDirLabel'#22'AnchorSideLeft.Control' +'chorSideTop.Control'#7#14'WorkingDirEdit'#18'AnchorSideTop.Side'#7#9'asrCen'
+#7#5'Owner'#21'AnchorSideTop.Control'#7#14'WorkingDirEdit'#18'AnchorSideTop.' +'ter'#4'Left'#2#6#6'Height'#2#20#3'Top'#2'^'#5'Width'#2'f'#18'BorderSpacing.'
+'Side'#7#9'asrCenter'#4'Left'#2#6#6'Height'#2#20#3'Top'#2'^'#5'Width'#2'f'#18 +'Left'#2#6#7'Caption'#6#15'WorkingDirLabel'#11'ParentColor'#8#0#0#5'TEdit'#9
+'BorderSpacing.Left'#2#6#7'Caption'#6#15'WorkingDirLabel'#11'ParentColor'#8#0 +'TitleEdit'#21'AnchorSideTop.Control'#7#5'Owner'#23'AnchorSideRight.Control'
+#0#5'TEdit'#9'TitleEdit'#21'AnchorSideTop.Control'#7#5'Owner'#23'AnchorSideR' +#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#3#128#0#6'Height'
+'ight.Control'#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#3 +#2#23#3'Top'#2#6#5'Width'#3#15#2#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'
+#128#0#6'Height'#2#23#3'Top'#2#6#5'Width'#3#15#2#7'Anchors'#11#5'akTop'#6'ak' +#0#20'BorderSpacing.Around'#2#6#8'TabOrder'#2#0#4'Text'#6#9'TitleEdit'#0#0#5
+'Left'#7'akRight'#0#20'BorderSpacing.Around'#2#6#8'TabOrder'#2#0#4'Text'#6#9 +'TEdit'#12'FilenameEdit'#22'AnchorSideLeft.Control'#7#9'TitleEdit'#21'Anchor'
+'TitleEdit'#0#0#5'TEdit'#12'FilenameEdit'#22'AnchorSideLeft.Control'#7#9'Tit' +'SideTop.Control'#7#9'TitleEdit'#18'AnchorSideTop.Side'#7#9'asrBottom'#23'An'
+'leEdit'#21'AnchorSideTop.Control'#7#9'TitleEdit'#18'AnchorSideTop.Side'#7#9 +'chorSideRight.Control'#7#10'OpenButton'#4'Left'#3#128#0#6'Height'#2#23#3'To'
+'asrBottom'#23'AnchorSideRight.Control'#7#10'OpenButton'#4'Left'#3#128#0#6'H' +'p'#2'#'#5'Width'#3#241#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#17'B'
+'eight'#2#23#3'Top'#2'#'#5'Width'#3#241#1#7'Anchors'#11#5'akTop'#6'akLeft'#7 +'orderSpacing.Top'#2#6#19'BorderSpacing.Right'#2#6#8'TabOrder'#2#1#4'Text'#6
+'akRight'#0#17'BorderSpacing.Top'#2#6#19'BorderSpacing.Right'#2#6#8'TabOrder' +#12'FilenameEdit'#0#0#7'TButton'#10'OpenButton'#21'AnchorSideTop.Control'#7
+#2#1#4'Text'#6#12'FilenameEdit'#0#0#7'TButton'#10'OpenButton'#21'AnchorSideT' +#12'FilenameEdit'#23'AnchorSideRight.Control'#7#5'Owner'#20'AnchorSideRight.'
+'op.Control'#7#12'FilenameEdit'#23'AnchorSideRight.Control'#7#5'Owner'#20'An' +'Side'#7#9'asrBottom'#24'AnchorSideBottom.Control'#7#12'FilenameEdit'#21'Anc'
+'chorSideRight.Side'#7#9'asrBottom'#24'AnchorSideBottom.Control'#7#12'Filena' +'horSideBottom.Side'#7#9'asrBottom'#4'Left'#3'w'#2#6'Height'#2#23#3'Top'#2'#'
+'meEdit'#21'AnchorSideBottom.Side'#7#9'asrBottom'#4'Left'#3'w'#2#6'Height'#2 +#5'Width'#2#24#7'Anchors'#11#5'akTop'#7'akRight'#8'akBottom'#0#8'AutoSize'#9
+#23#3'Top'#2'#'#5'Width'#2#24#7'Anchors'#11#5'akTop'#7'akRight'#8'akBottom'#0 +#19'BorderSpacing.Right'#2#6#7'Caption'#6#3'...'#7'OnClick'#7#15'OpenButtonC'
+#8'AutoSize'#9#19'BorderSpacing.Right'#2#6#7'Caption'#6#3'...'#7'OnClick'#7 +'lick'#14'ParentShowHint'#8#8'ShowHint'#9#8'TabOrder'#2#2#0#0#5'TEdit'#14'Pa'
+#15'OpenButtonClick'#14'ParentShowHint'#8#8'ShowHint'#9#8'TabOrder'#2#2#0#0#5 +'rametersEdit'#22'AnchorSideLeft.Control'#7#9'TitleEdit'#21'AnchorSideTop.Co'
+'TEdit'#14'ParametersEdit'#22'AnchorSideLeft.Control'#7#9'TitleEdit'#21'Anch' +'ntrol'#7#12'FilenameEdit'#18'AnchorSideTop.Side'#7#9'asrBottom'#23'AnchorSi'
+'orSideTop.Control'#7#12'FilenameEdit'#18'AnchorSideTop.Side'#7#9'asrBottom' +'deRight.Control'#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'
+#23'AnchorSideRight.Control'#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBott' +#3#128#0#6'Height'#2#23#3'Top'#2'@'#5'Width'#3#15#2#7'Anchors'#11#5'akTop'#6
+'om'#4'Left'#3#128#0#6'Height'#2#23#3'Top'#2'@'#5'Width'#3#15#2#7'Anchors'#11
+#5'akTop'#6'akLeft'#7'akRight'#0#17'BorderSpacing.Top'#2#6#19'BorderSpacing.'
+'Right'#2#6#8'TabOrder'#2#3#4'Text'#6#14'ParametersEdit'#0#0#5'TEdit'#14'Wor'
+'kingDirEdit'#22'AnchorSideLeft.Control'#7#9'TitleEdit'#21'AnchorSideTop.Con'
+'trol'#7#14'ParametersEdit'#18'AnchorSideTop.Side'#7#9'asrBottom'#23'AnchorS'
+'ideRight.Control'#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'
+#3#128#0#6'Height'#2#23#3'Top'#2']'#5'Width'#3#15#2#7'Anchors'#11#5'akTop'#6
+'akLeft'#7'akRight'#0#17'BorderSpacing.Top'#2#6#19'BorderSpacing.Right'#2#6#8 +'akLeft'#7'akRight'#0#17'BorderSpacing.Top'#2#6#19'BorderSpacing.Right'#2#6#8
+'TabOrder'#2#4#4'Text'#6#14'WorkingDirEdit'#0#0#9'TGroupBox'#15'OptionsGroup' +'TabOrder'#2#3#4'Text'#6#14'ParametersEdit'#0#0#5'TEdit'#14'WorkingDirEdit'
+'Box'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7#14'W' +#22'AnchorSideLeft.Control'#7#9'TitleEdit'#21'AnchorSideTop.Control'#7#14'Pa'
+'orkingDirEdit'#18'AnchorSideTop.Side'#7#9'asrBottom'#23'AnchorSideRight.Con' +'rametersEdit'#18'AnchorSideTop.Side'#7#9'asrBottom'#23'AnchorSideRight.Cont'
+'trol'#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#2#6#6'Heig' +'rol'#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#3#128#0#6'H'
+'ht'#2'\'#3'Top'#2'z'#5'Width'#3#137#2#7'Anchors'#11#5'akTop'#6'akLeft'#7'ak' +'eight'#2#23#3'Top'#2']'#5'Width'#3#15#2#7'Anchors'#11#5'akTop'#6'akLeft'#7
+'Right'#0#8'AutoSize'#9#20'BorderSpacing.Around'#2#6#7'Caption'#6#15'Options' +'akRight'#0#17'BorderSpacing.Top'#2#6#19'BorderSpacing.Right'#2#6#8'TabOrder'
+'GroupBox'#18'ChildSizing.Layout'#7#29'cclTopToBottomThenLeftToRight'#27'Chi' +#2#4#4'Text'#6#14'WorkingDirEdit'#0#0#9'TGroupBox'#15'OptionsGroupBox'#22'An'
+'ldSizing.ControlsPerLine'#2#5#12'ClientHeight'#2'I'#11'ClientWidth'#3#133#2 +'chorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7#14'WorkingDirE'
+#8'TabOrder'#2#5#0#9'TCheckBox&OptionScanOutputForFPCMessagesCheckBox'#6'Hei' +'dit'#18'AnchorSideTop.Side'#7#9'asrBottom'#23'AnchorSideRight.Control'#7#5
+'ght'#2#22#5'Width'#3'C'#1#7'Caption'#6'&OptionScanOutputForFPCMessagesCheck' +'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#2#6#6'Height'#2'\'#3
+'Box'#8'TabOrder'#2#0#0#0#9'TCheckBox''OptionScanOutputForMakeMessagesCheckB' +'Top'#2'z'#5'Width'#3#137#2#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#8
+'ox'#18'AnchorSideTop.Side'#7#9'asrBottom'#21'AnchorSideBottom.Side'#7#9'asr' +'AutoSize'#9#20'BorderSpacing.Around'#2#6#7'Caption'#6#15'OptionsGroupBox'#18
+'Bottom'#6'Height'#2#22#3'Top'#2#22#5'Width'#3'C'#1#7'Caption'#6'''OptionSca' +'ChildSizing.Layout'#7#29'cclTopToBottomThenLeftToRight'#27'ChildSizing.Cont'
+'nOutputForMakeMessagesCheckBox'#8'TabOrder'#2#1#0#0#7'TButton'#14'ScannersB' +'rolsPerLine'#2#5#12'ClientHeight'#2'I'#11'ClientWidth'#3#133#2#8'TabOrder'#2
+'utton'#6'Height'#2#29#3'Top'#2','#5'Width'#3'C'#1#7'Caption'#6#14'ScannersB' +#5#0#9'TCheckBox&OptionScanOutputForFPCMessagesCheckBox'#6'Height'#2#22#5'Wi'
,'utton'#7'OnClick'#7#19'ScannersButtonClick'#8'TabOrder'#2#2#0#0#0#9'TGroupB' +'dth'#3'C'#1#7'Caption'#6'&OptionScanOutputForFPCMessagesCheckBox'#8'TabOrde'
+'ox'#11'KeyGroupBox'#22'AnchorSideLeft.Control'#7#15'OptionsGroupBox'#21'Anc' +'r'#2#0#0#0#9'TCheckBox''OptionScanOutputForMakeMessagesCheckBox'#18'AnchorS'
+'horSideTop.Control'#7#15'OptionsGroupBox'#18'AnchorSideTop.Side'#7#9'asrBot' +'ideTop.Side'#7#9'asrBottom'#21'AnchorSideBottom.Side'#7#9'asrBottom'#6'Heig'
+'tom'#23'AnchorSideRight.Control'#7#15'OptionsGroupBox'#20'AnchorSideRight.S' +'ht'#2#22#3'Top'#2#22#5'Width'#3'C'#1#7'Caption'#6'''OptionScanOutputForMake'
+'ide'#7#9'asrBottom'#4'Left'#2#6#6'Height'#2'1'#3'Top'#3#220#0#5'Width'#3#137 +'MessagesCheckBox'#8'TabOrder'#2#1#0#0#7'TButton'#14'ScannersButton'#6'Heigh'
+#2#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#8'AutoSize'#9#17'BorderSpac' +'t'#2#29#3'Top'#2','#5'Width'#3'C'#1#7'Caption'#6#14'ScannersButton'#7'OnCli'
+'ing.Top'#2#6#7'Caption'#6#11'KeyGroupBox'#12'ClientHeight'#2#30#11'ClientWi' +'ck'#7#19'ScannersButtonClick'#8'TabOrder'#2#2#0#0#0#9'TGroupBox'#11'KeyGrou'
+'dth'#3#133#2#8'TabOrder'#2#6#0#9'TCheckBox'#15'KeyCtrlCheckBox'#22'AnchorSi' ,'pBox'#22'AnchorSideLeft.Control'#7#15'OptionsGroupBox'#21'AnchorSideTop.Con'
+'deLeft.Control'#7#11'KeyGroupBox'#21'AnchorSideTop.Control'#7#11'KeyGroupBo' +'trol'#7#15'OptionsGroupBox'#18'AnchorSideTop.Side'#7#9'asrBottom'#23'Anchor'
+'x'#24'AnchorSideBottom.Control'#7#11'KeyGroupBox'#21'AnchorSideBottom.Side' +'SideRight.Control'#7#15'OptionsGroupBox'#20'AnchorSideRight.Side'#7#9'asrBo'
+#7#9'asrBottom'#4'Left'#2#6#6'Height'#2#22#3'Top'#2#2#5'Width'#3#131#0#7'Anc' +'ttom'#4'Left'#2#6#6'Height'#2#25#3'Top'#3#220#0#5'Width'#3#137#2#7'Anchors'
+'hors'#11#5'akTop'#6'akLeft'#8'akBottom'#0#18'BorderSpacing.Left'#2#6#17'Bor' +#11#5'akTop'#6'akLeft'#7'akRight'#0#8'AutoSize'#9#17'BorderSpacing.Top'#2#6#7
+'derSpacing.Top'#2#2#20'BorderSpacing.Bottom'#2#6#7'Caption'#6#15'KeyCtrlChe' +'Caption'#6#11'KeyGroupBox'#21'Constraints.MinHeight'#2#25#8'TabOrder'#2#6#0
+'ckBox'#8'TabOrder'#2#0#0#0#9'TCheckBox'#14'KeyAltCheckBox'#22'AnchorSideLef' +#0#9'TGroupBox'#14'MacrosGroupbox'#22'AnchorSideLeft.Control'#7#5'Owner'#21
+'t.Control'#7#15'KeyCtrlCheckBox'#19'AnchorSideLeft.Side'#7#9'asrBottom'#21 +'AnchorSideTop.Control'#7#11'KeyGroupBox'#18'AnchorSideTop.Side'#7#9'asrBott'
+'AnchorSideTop.Control'#7#15'KeyCtrlCheckBox'#4'Left'#3#143#0#6'Height'#2#22 +'om'#23'AnchorSideRight.Control'#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asr'
+#3'Top'#2#2#5'Width'#2'~'#18'BorderSpacing.Left'#2#6#7'Caption'#6#14'KeyAltC' +'Bottom'#24'AnchorSideBottom.Control'#7#8'BtnPanel'#4'Left'#2#6#6'Height'#3
+'heckBox'#8'TabOrder'#2#1#0#0#9'TCheckBox'#16'KeyShiftCheckBox'#22'AnchorSid' +#196#0#3'Top'#3#251#0#5'Width'#3#137#2#7'Anchors'#11#5'akTop'#6'akLeft'#7'ak'
+'eLeft.Control'#7#14'KeyAltCheckBox'#19'AnchorSideLeft.Side'#7#9'asrBottom' +'Right'#8'akBottom'#0#20'BorderSpacing.Around'#2#6#7'Caption'#6#14'MacrosGro'
+#21'AnchorSideTop.Control'#7#15'KeyCtrlCheckBox'#4'Left'#3#19#1#6'Height'#2 +'upbox'#12'ClientHeight'#3#177#0#11'ClientWidth'#3#133#2#8'TabOrder'#2#7#0#8
+#22#3'Top'#2#2#5'Width'#3#138#0#18'BorderSpacing.Left'#2#6#7'Caption'#6#16'K' +'TListBox'#13'MacrosListbox'#22'AnchorSideLeft.Control'#7#14'MacrosGroupbox'
+'eyShiftCheckBox'#8'TabOrder'#2#2#0#0#9'TComboBox'#11'KeyComboBox'#22'Anchor' +#21'AnchorSideTop.Control'#7#18'MacrosInsertButton'#23'AnchorSideRight.Contr'
+'SideLeft.Control'#7#16'KeyShiftCheckBox'#19'AnchorSideLeft.Side'#7#9'asrBot' +'ol'#7#18'MacrosInsertButton'#24'AnchorSideBottom.Control'#7#14'MacrosGroupb'
+'tom'#21'AnchorSideTop.Control'#7#15'KeyCtrlCheckBox'#18'AnchorSideTop.Side' +'ox'#21'AnchorSideBottom.Side'#7#9'asrBottom'#4'Left'#2#6#6'Height'#3#169#0#3
+#7#9'asrCenter'#23'AnchorSideRight.Control'#7#13'KeyGrabButton'#4'Left'#3#163 +'Top'#2#2#5'Width'#3#234#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8'akB'
+#1#6'Height'#2#29#3'Top'#2#255#5'Width'#2'j'#7'Anchors'#11#5'akTop'#6'akLeft' +'ottom'#0#18'BorderSpacing.Left'#2#6#19'BorderSpacing.Right'#2#6#20'BorderSp'
+#7'akRight'#0#16'AutoCompleteText'#11#22'cbactEndOfLineComplete'#20'cbactSea' +'acing.Bottom'#2#6#7'OnClick'#7#18'MacrosListboxClick'#8'TabOrder'#2#0#8'Top'
+'rchAscending'#0#18'BorderSpacing.Left'#2#6#19'BorderSpacing.Right'#2#6#9'Ma' +'Index'#2#255#0#0#7'TButton'#18'MacrosInsertButton'#21'AnchorSideTop.Control'
+'xLength'#2#0#8'TabOrder'#2#3#4'Text'#6#11'KeyComboBox'#0#0#7'TButton'#13'Ke' +#7#14'MacrosGroupbox'#23'AnchorSideRight.Control'#7#14'MacrosGroupbox'#20'An'
+'yGrabButton'#21'AnchorSideTop.Control'#7#15'KeyCtrlCheckBox'#18'AnchorSideT' +'chorSideRight.Side'#7#9'asrBottom'#4'Left'#3#246#1#6'Height'#2#29#3'Top'#2#2
+'op.Side'#7#9'asrCenter'#23'AnchorSideRight.Control'#7#11'KeyGroupBox'#20'An' +#5'Width'#3#137#0#7'Anchors'#11#5'akTop'#7'akRight'#0#8'AutoSize'#9#17'Borde'
+'chorSideRight.Side'#7#9'asrBottom'#21'AnchorSideBottom.Side'#7#9'asrBottom' +'rSpacing.Top'#2#2#19'BorderSpacing.Right'#2#6#7'Caption'#6#18'MacrosInsertB'
+#4'Left'#3#19#2#6'Height'#2#29#3'Top'#2#254#5'Width'#2'l'#7'Anchors'#11#7'ak' +'utton'#7'Enabled'#8#7'OnClick'#7#23'MacrosInsertButtonClick'#8'TabOrder'#2#1
+'Right'#0#8'AutoSize'#9#18'BorderSpacing.Left'#2#6#19'BorderSpacing.Right'#2 +#0#0#0#6'TPanel'#8'BtnPanel'#6'Height'#2'0'#3'Top'#3#197#1#5'Width'#3#149#2#5
+#6#7'Caption'#6#13'KeyGrabButton'#7'OnClick'#7#18'KeyGrabButtonClick'#8'TabO' +'Align'#7#8'alBottom'#8'AutoSize'#9#10'BevelOuter'#7#6'bvNone'#12'ClientHeig'
+'rder'#2#4#0#0#0#9'TGroupBox'#14'MacrosGroupbox'#22'AnchorSideLeft.Control'#7 +'ht'#2'0'#11'ClientWidth'#3#149#2#8'TabOrder'#2#8#0#7'TBitBtn'#8'OKButton'#21
+#5'Owner'#21'AnchorSideTop.Control'#7#11'KeyGroupBox'#18'AnchorSideTop.Side' +'AnchorSideBottom.Side'#7#9'asrBottom'#4'Left'#3#245#1#6'Height'#2'$'#3'Top'
+#7#9'asrBottom'#23'AnchorSideRight.Control'#7#5'Owner'#20'AnchorSideRight.Si' +#2#6#5'Width'#2'I'#5'Align'#7#7'alRight'#20'BorderSpacing.Around'#2#6#7'Capt'
+'de'#7#9'asrBottom'#24'AnchorSideBottom.Control'#7#8'BtnPanel'#4'Left'#2#6#6 +'ion'#6#2'Ok'#7'Default'#9#4'Kind'#7#4'bkOK'#11'ModalResult'#2#1#9'NumGlyphs'
+'Height'#3#172#0#3'Top'#3#19#1#5'Width'#3#137#2#7'Anchors'#11#5'akTop'#6'akL' +#2#0#7'OnClick'#7#13'OKButtonClick'#8'TabOrder'#2#0#0#0#7'TBitBtn'#12'Cancel'
+'eft'#7'akRight'#8'akBottom'#0#20'BorderSpacing.Around'#2#6#7'Caption'#6#14 +'Button'#20'AnchorSideRight.Side'#7#9'asrBottom'#21'AnchorSideBottom.Side'#7
+'MacrosGroupbox'#12'ClientHeight'#3#153#0#11'ClientWidth'#3#133#2#8'TabOrder' +#9'asrBottom'#4'Left'#3'D'#2#6'Height'#2'$'#3'Top'#2#6#5'Width'#2'K'#5'Align'
+#2#7#0#8'TListBox'#13'MacrosListbox'#22'AnchorSideLeft.Control'#7#14'MacrosG' +#7#7'alRight'#20'BorderSpacing.Around'#2#6#6'Cancel'#9#7'Caption'#6#6'Cancel'
+'roupbox'#21'AnchorSideTop.Control'#7#18'MacrosInsertButton'#23'AnchorSideRi' +#4'Kind'#7#8'bkCancel'#11'ModalResult'#2#2#9'NumGlyphs'#2#0#8'TabOrder'#2#1#0
+'ght.Control'#7#18'MacrosInsertButton'#24'AnchorSideBottom.Control'#7#14'Mac' +#0#0#11'TOpenDialog'#10'OpenDialog'#7'Options'#11#15'ofPathMustExist'#15'ofF'
+'rosGroupbox'#21'AnchorSideBottom.Side'#7#9'asrBottom'#4'Left'#2#6#6'Height' +'ileMustExist'#14'ofEnableSizing'#12'ofViewDetail'#0#4'left'#2'X'#3'top'#2' '
+#3#145#0#3'Top'#2#2#5'Width'#3#234#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRi' +#0#0#0
+'ght'#8'akBottom'#0#18'BorderSpacing.Left'#2#6#19'BorderSpacing.Right'#2#6#20
+'BorderSpacing.Bottom'#2#6#7'OnClick'#7#18'MacrosListboxClick'#8'TabOrder'#2
+#0#8'TopIndex'#2#255#0#0#7'TButton'#18'MacrosInsertButton'#21'AnchorSideTop.'
+'Control'#7#14'MacrosGroupbox'#23'AnchorSideRight.Control'#7#14'MacrosGroupb'
+'ox'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#3#246#1#6'Height'#2#29#3
+'Top'#2#2#5'Width'#3#137#0#7'Anchors'#11#5'akTop'#7'akRight'#0#8'AutoSize'#9
+#17'BorderSpacing.Top'#2#2#19'BorderSpacing.Right'#2#6#7'Caption'#6#18'Macro'
+'sInsertButton'#7'Enabled'#8#7'OnClick'#7#23'MacrosInsertButtonClick'#8'TabO'
+'rder'#2#1#0#0#0#6'TPanel'#8'BtnPanel'#6'Height'#2'0'#3'Top'#3#197#1#5'Width'
+#3#149#2#5'Align'#7#8'alBottom'#8'AutoSize'#9#10'BevelOuter'#7#6'bvNone'#12
+'ClientHeight'#2'0'#11'ClientWidth'#3#149#2#8'TabOrder'#2#8#0#7'TBitBtn'#8'O'
+'KButton'#21'AnchorSideBottom.Side'#7#9'asrBottom'#4'Left'#3#245#1#6'Height'
+#2'$'#3'Top'#2#6#5'Width'#2'I'#5'Align'#7#7'alRight'#20'BorderSpacing.Around'
+#2#6#7'Caption'#6#2'Ok'#7'Default'#9#4'Kind'#7#4'bkOK'#11'ModalResult'#2#1#9
+'NumGlyphs'#2#0#7'OnClick'#7#13'OKButtonClick'#8'TabOrder'#2#0#0#0#7'TBitBtn'
+#12'CancelButton'#20'AnchorSideRight.Side'#7#9'asrBottom'#21'AnchorSideBotto'
+'m.Side'#7#9'asrBottom'#4'Left'#3'D'#2#6'Height'#2'$'#3'Top'#2#6#5'Width'#2
,'K'#5'Align'#7#7'alRight'#20'BorderSpacing.Around'#2#6#6'Cancel'#9#7'Caption'
+#6#6'Cancel'#4'Kind'#7#8'bkCancel'#11'ModalResult'#2#2#9'NumGlyphs'#2#0#8'Ta'
+'bOrder'#2#1#0#0#0#11'TOpenDialog'#10'OpenDialog'#7'Options'#11#15'ofPathMus'
+'tExist'#15'ofFileMustExist'#14'ofEnableSizing'#12'ofViewDetail'#0#4'left'#2
+'X'#3'top'#2' '#0#0#0
]); ]);

View File

@ -45,7 +45,8 @@ uses
Classes, SysUtils, LCLType, Controls, Forms, Buttons, StdCtrls, ComCtrls, Classes, SysUtils, LCLType, Controls, Forms, Buttons, StdCtrls, ComCtrls,
Dialogs, LResources, ExtCtrls, LCLProc, Dialogs, LResources, ExtCtrls, LCLProc,
IDEMsgIntf, IDEExternToolIntf, IDEMsgIntf, IDEExternToolIntf,
KeyMapping, TransferMacros, LazarusIDEStrConsts, EditMsgScannersDlg; KeyMapping, KeyMapShortCutDlg, TransferMacros, LazarusIDEStrConsts,
EditMsgScannersDlg;
type type
{ TExternalToolOptions } { TExternalToolOptions }
@ -82,11 +83,6 @@ type
OptionScanOutputForFPCMessagesCheckBox: TCheckBox; OptionScanOutputForFPCMessagesCheckBox: TCheckBox;
OptionScanOutputForMakeMessagesCheckBox: TCheckBox; OptionScanOutputForMakeMessagesCheckBox: TCheckBox;
KeyGroupBox: TGroupBox; KeyGroupBox: TGroupBox;
KeyCtrlCheckBox: TCheckBox;
KeyAltCheckBox: TCheckBox;
KeyShiftCheckBox: TCheckBox;
KeyComboBox: TComboBox;
KeyGrabButton: TButton;
MacrosGroupbox: TGroupbox; MacrosGroupbox: TGroupbox;
MacrosListbox: TListbox; MacrosListbox: TListbox;
MacrosInsertButton: TButton; MacrosInsertButton: TButton;
@ -94,8 +90,6 @@ type
CancelButton: TBitBtn; CancelButton: TBitBtn;
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject); procedure FormDestroy(Sender: TObject);
procedure FormKeyUp(Sender: TObject; var Key: Word; Shift:TShiftState);
procedure KeyGrabButtonClick(Sender: TObject);
procedure MacrosInsertButtonClick(Sender: TObject); procedure MacrosInsertButtonClick(Sender: TObject);
procedure MacrosListboxClick(Sender: TObject); procedure MacrosListboxClick(Sender: TObject);
procedure OKButtonClick(Sender: TObject); procedure OKButtonClick(Sender: TObject);
@ -105,9 +99,7 @@ type
fOptions: TExternalToolOptions; fOptions: TExternalToolOptions;
fTransferMacros: TTransferMacroList; fTransferMacros: TTransferMacroList;
fScanners: TStrings; fScanners: TStrings;
GrabbingKey: integer; // 0=none, 1=Default key fKeyBox: TShortCutGrabBox;
procedure ActivateGrabbing(AGrabbingKey: integer);
procedure DeactivateGrabbing;
procedure FillMacroList; procedure FillMacroList;
procedure LoadFromOptions; procedure LoadFromOptions;
procedure SaveToOptions; procedure SaveToOptions;
@ -168,16 +160,8 @@ begin
fOptions.Filename:=FilenameEdit.Text; fOptions.Filename:=FilenameEdit.Text;
fOptions.CmdLineParams:=ParametersEdit.Text; fOptions.CmdLineParams:=ParametersEdit.Text;
fOptions.WorkingDirectory:=WorkingDirEdit.Text; fOptions.WorkingDirectory:=WorkingDirEdit.Text;
fOptions.Key:=EditorKeyStringToVKCode(KeyComboBox.Text); fOptions.Key:=fKeyBox.Key;
fOptions.Shift:=[]; fOptions.Shift:=fKeyBox.ShiftState;
if fOptions.Key<>VK_UNKNOWN then begin
if KeyCtrlCheckBox.Checked then
fOptions.Shift := fOptions.Shift + [ssCtrl];
if KeyAltCheckBox.Checked then
fOptions.Shift := fOptions.Shift + [ssAlt];
if KeyShiftCheckBox.Checked then
fOptions.Shift := fOptions.Shift + [ssShift];
end;
fOptions.ScanOutputForFPCMessages:= fOptions.ScanOutputForFPCMessages:=
OptionScanOutputForFPCMessagesCheckBox.Checked; OptionScanOutputForFPCMessagesCheckBox.Checked;
fOptions.ScanOutputForMakeMessages:= fOptions.ScanOutputForMakeMessages:=
@ -222,10 +206,8 @@ begin
FilenameEdit.Text:=fOptions.Filename; FilenameEdit.Text:=fOptions.Filename;
ParametersEdit.Text:=fOptions.CmdLineParams; ParametersEdit.Text:=fOptions.CmdLineParams;
WorkingDirEdit.Text:=fOptions.WorkingDirectory; WorkingDirEdit.Text:=fOptions.WorkingDirectory;
SetComboBox(KeyComboBox,KeyAndShiftStateToEditorKeyString(fOptions.Key,[])); fKeyBox.Key:=fOptions.Key;
KeyCtrlCheckBox.Checked:=(ssCtrl in fOptions.Shift); fKeyBox.ShiftState:=fOptions.Shift;
KeyShiftCheckBox.Checked:=(ssShift in fOptions.Shift);
KeyAltCheckBox.Checked:=(ssAlt in fOptions.Shift);
OptionScanOutputForFPCMessagesCheckBox.Checked:= OptionScanOutputForFPCMessagesCheckBox.Checked:=
fOptions.ScanOutputForFPCMessages; fOptions.ScanOutputForFPCMessages;
OptionScanOutputForMakeMessagesCheckBox.Checked:= OptionScanOutputForMakeMessagesCheckBox.Checked:=
@ -235,12 +217,8 @@ begin
end; end;
procedure TExternalToolOptionDlg.FormCreate(Sender: TObject); procedure TExternalToolOptionDlg.FormCreate(Sender: TObject);
var
i: word;
s: string;
begin begin
fScanners:=TStringList.Create; fScanners:=TStringList.Create;
GrabbingKey:=0;
Caption:=lisEdtExtToolEditTool; Caption:=lisEdtExtToolEditTool;
TitleLabel.Caption:=dlgPOTitle; TitleLabel.Caption:=dlgPOTitle;
@ -269,30 +247,14 @@ begin
with KeyGroupBox do with KeyGroupBox do
Caption:=lisEdtExtToolKey; Caption:=lisEdtExtToolKey;
with KeyCtrlCheckBox do fKeyBox:=TShortCutGrabBox.Create(Self);
Caption:=lisEdtExtToolCtrl; with fKeyBox do begin
Name:='fKeyBox';
with KeyAltCheckBox do Align:=alClient;
Caption:=lisEdtExtToolAlt; BorderSpacing.Around:=6;
Parent:=KeyGroupBox;
with KeyShiftCheckBox do
Caption:=lisEdtExtToolShift;
with KeyComboBox do begin
Items.BeginUpdate;
Items.Add(srVK_NONE);
for i:=1 to 145 do begin
s:=KeyAndShiftStateToEditorKeyString(i,[]);
if not EditorKeyStringIsIrregular(s) then
Items.Add(s);
end;
Items.EndUpdate;
ItemIndex:=0;
end; end;
with KeyGrabButton do
Caption:=srkmGrabKey;
with MacrosGroupbox do with MacrosGroupbox do
Caption:=lisEdtExtToolMacros; Caption:=lisEdtExtToolMacros;
@ -311,11 +273,6 @@ begin
FreeAndNil(fScanners); FreeAndNil(fScanners);
end; end;
procedure TExternalToolOptionDlg.KeyGrabButtonClick(Sender: TObject);
begin
ActivateGrabbing(1);
end;
procedure TExternalToolOptionDlg.SetOptions(TheOptions: TExternalToolOptions); procedure TExternalToolOptionDlg.SetOptions(TheOptions: TExternalToolOptions);
begin begin
if fOptions=TheOptions then exit; if fOptions=TheOptions then exit;
@ -364,58 +321,6 @@ begin
end; end;
end; end;
procedure TExternalToolOptionDlg.DeactivateGrabbing;
var i: integer;
begin
if GrabbingKey=0 then exit;
// enable all components
for i:=0 to ComponentCount-1 do begin
if (Components[i] is TWinControl) then
TWinControl(Components[i]).Enabled:=true;
end;
if GrabbingKey=1 then
KeyGrabButton.Caption:=srkmGrabKey;
GrabbingKey:=0;
end;
procedure TExternalToolOptionDlg.ActivateGrabbing(AGrabbingKey: integer);
var i: integer;
begin
if GrabbingKey>0 then exit;
GrabbingKey:=AGrabbingKey;
if GrabbingKey=0 then exit;
// disable all components
for i:=0 to ComponentCount-1 do begin
if (Components[i] is TWinControl) then begin
if ((GrabbingKey=1) and (Components[i]<>KeyGrabButton)
and (Components[i]<>KeyGroupBox)) then
TWinControl(Components[i]).Enabled:=false;
end;
end;
if GrabbingKey=1 then
KeyGrabButton.Caption:=srkmPressKey;
end;
procedure TExternalToolOptionDlg.FormKeyUp(Sender: TObject; var Key: Word;
Shift:TShiftState);
begin
//writeln('TExternalToolOptionDlg.FormKeyUp Sender=',Classname
// ,' Key=',Key,' Ctrl=',ssCtrl in Shift,' Shift=',ssShift in Shift
// ,' Alt=',ssAlt in Shift,' AsString=',KeyAndShiftStateToStr(Key,Shift)
// );
if Key in [VK_CONTROL, VK_SHIFT, VK_LCONTROL, VK_RCONTROl,
VK_LSHIFT, VK_RSHIFT] then exit;
if (GrabbingKey in [1]) then begin
if GrabbingKey=1 then begin
KeyCtrlCheckBox.Checked:=(ssCtrl in Shift);
KeyShiftCheckBox.Checked:=(ssShift in Shift);
KeyAltCheckBox.Checked:=(ssAlt in Shift);
SetComboBox(KeyComboBox,KeyAndShiftStateToEditorKeyString(Key,[]));
end;
DeactivateGrabbing;
end;
end;
procedure TExternalToolOptionDlg.MacrosInsertButtonClick(Sender: TObject); procedure TExternalToolOptionDlg.MacrosInsertButtonClick(Sender: TObject);
var i: integer; var i: integer;
s: string; s: string;

View File

@ -36,7 +36,7 @@ uses
Forms, Classes, SysUtils, Buttons, LResources, StdCtrls, Controls, Forms, Classes, SysUtils, Buttons, LResources, StdCtrls, Controls,
Dialogs, StringHashList, ExtCtrls, Dialogs, StringHashList, ExtCtrls,
SynEditKeyCmds, Laz_XMLCfg, SynEditKeyCmds, Laz_XMLCfg,
LazarusIDEStrConsts, IDECommands; IDECommands, LazarusIDEStrConsts;
type type
TKeyMapScheme = ( TKeyMapScheme = (
@ -136,159 +136,10 @@ type
property Relations[Index:integer]:TKeyCommandRelation read GetRelation; default; property Relations[Index:integer]:TKeyCommandRelation read GetRelation; default;
property RelationCount:integer read GetRelationCount; property RelationCount:integer read GetRelationCount;
end; end;
{ TCustomShortCutGrabBox }
TCustomShortCutGrabBox = class(TCustomPanel)
private
FAllowedShifts: TShiftState;
FGrabButton: TButton;
FKey: Word;
FKeyComboBox: TComboBox;
FShiftButtons: TShiftState;
FShiftState: TShiftState;
FCheckBoxes: array[TShiftStateEnum] of TCheckBox;
FGrabForm: TForm;
function GetShiftCheckBox(Shift: TShiftStateEnum): TCheckBox;
procedure SetAllowedShifts(const AValue: TShiftState);
procedure SetKey(const AValue: Word);
procedure SetShiftButtons(const AValue: TShiftState);
procedure SetShiftState(const AValue: TShiftState);
procedure OnGrabButtonClick(Sender: TObject);
procedure OnShitCheckBoxClick(Sender: TObject);
procedure OnGrabFormKeyDown(Sender: TObject; var AKey: Word;
AShift: TShiftState);
procedure OnKeyComboboxEditingDone(Sender: TObject);
protected
procedure Loaded; override;
procedure UpdateShiftButons;
procedure Notification(AComponent: TComponent; Operation: TOperation);
override;
function ShiftToStr(s: TShiftStateEnum): string;
public
constructor Create(TheOwner: TComponent); override;
function GetDefaultShiftButtons: TShiftState;
property ShiftState: TShiftState read FShiftState write SetShiftState;
property Key: Word read FKey write SetKey;
property ShiftButtons: TShiftState read FShiftButtons write SetShiftButtons;
property AllowedShifts: TShiftState read FAllowedShifts write SetAllowedShifts;
property KeyComboBox: TComboBox read FKeyComboBox;
property GrabButton: TButton read FGrabButton;
property ShiftCheckBox[Shift: TShiftStateEnum]: TCheckBox read GetShiftCheckBox;
end;
{ TShortCutGrabBox }
TShortCutGrabBox = class(TCustomShortCutGrabBox)
published
property Align;
property Alignment;
property Anchors;
property AutoSize;
property BorderSpacing;
property BevelInner;
property BevelOuter;
property BevelWidth;
property BorderWidth;
property BorderStyle;
property Caption;
property ChildSizing;
property ClientHeight;
property ClientWidth;
property Color;
property Constraints;
property DockSite;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Font;
property FullRepaint;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabOrder;
property TabStop;
property UseDockManager default True;
property Visible;
property OnClick;
property OnDockDrop;
property OnDockOver;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnGetSiteInfo;
property OnGetDockCaption;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnStartDock;
property OnStartDrag;
property OnUnDock;
end;
TKMEditFormMode = (
kmefmEdit,
kmefmGrab
);
{ TKeyMappingEditForm - form for editing one command - key relationship }
TKeyMappingEditForm = class(TForm)
public
OkButton: TButton;
CancelButton: TButton;
CommandLabel: TLabel;
KeyGroupBox: array[0..1] of TGroupBox;
KeyCtrlCheckBox: array[0..3] of TCheckBox;
KeyAltCheckBox: array[0..3] of TCheckBox;
KeyShiftCheckBox: array[0..3] of TCheckBox;
KeyComboBox: array[0..3] of TComboBox;
KeyGrabButton: array[0..3] of TButton;
procedure OkButtonClick(Sender: TObject);
procedure CancelButtonClick(Sender: TObject);
procedure KeyGrabButtonClick(Sender: TObject);
protected
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
private
FMode: TKMEditFormMode;
GrabbingKey: integer; { 0=none,
1=Default key (1st in sequence),
2=Default key (second in sequence),
3=Alternative key (1st in sequence)
4=Alternative key (second in sequence) }
procedure ActivateGrabbing(AGrabbingKey: integer);
procedure DeactivateGrabbing;
procedure SetComboBox(AComboBox: TComboBox; const AValue: string);
function ResolveConflicts(Key: TIDEShortCut; Scope: TIDECommandScope): boolean;
procedure SetMode(const AValue: TKMEditFormMode);
procedure SetupFindView;
procedure CheckEditModeInput;
procedure CheckGrabModeInput;
public
constructor Create(TheOwner: TComponent); override;
KeyCommandRelationList: TKeyCommandRelationList;
KeyIndex: integer;
NewKeyA, NewKeyB: TIDEShortCut;
property Mode: TKMEditFormMode read FMode write SetMode;
end;
function KeyAndShiftStateToEditorKeyString( function KeyAndShiftStateToEditorKeyString(
Key: word; ShiftState: TShiftState): String; Key: word; ShiftState: TShiftState): String;
function KeyAndShiftStateToEditorKeyString(const Key: TIDEShortCut): String; function KeyAndShiftStateToEditorKeyString(const Key: TIDEShortCut): String;
function ShowKeyMappingEditForm(Index: integer;
AKeyCommandRelationList: TKeyCommandRelationList): TModalResult;
function ShowKeyMappingGrabForm(AKeyCommandRelationList: TKeyCommandRelationList;
out Key: TIDEShortCut): TModalResult;
function FindKeymapConflicts(Keymap: TKeyCommandRelationList; function FindKeymapConflicts(Keymap: TKeyCommandRelationList;
Protocol: TStrings; out Index1, Index2: integer): integer; Protocol: TStrings; out Index1, Index2: integer): integer;
function EditorCommandToDescriptionString(cmd: word): String; function EditorCommandToDescriptionString(cmd: word): String;
@ -308,8 +159,6 @@ function ShiftStateToStr(Shift: TShiftState): string;
function KeyValuesToStr(const ShortcutA, ShortcutB: TIDEShortCut): string; function KeyValuesToStr(const ShortcutA, ShortcutB: TIDEShortCut): string;
function EditorKeyStringIsIrregular(const s: string): boolean; function EditorKeyStringIsIrregular(const s: string): boolean;
var KeyMappingEditForm: TKeyMappingEditForm = nil;
const const
UnknownVKPrefix = 'Word('''; UnknownVKPrefix = 'Word(''';
UnknownVKPostfix = ''')'; UnknownVKPostfix = ''')';
@ -1295,74 +1144,6 @@ begin
Result:=false; Result:=false;
end; end;
function ShowKeyMappingEditForm(Index:integer;
AKeyCommandRelationList: TKeyCommandRelationList):TModalResult;
procedure InitComboBox(AComboBox: TComboBox; AKey: word);
var s: string;
i: integer;
begin
s:=KeyAndShiftStateToEditorKeyString(AKey,[]);
i:=AComboBox.Items.IndexOf(s);
if i>=0 then
AComboBox.ItemIndex:=i
else if EditorKeyStringIsIrregular(s) then begin
AComboBox.Items.Add(s);
AComboBox.ItemIndex:=AComboBox.Items.IndexOf(s);
end else
AComboBox.ItemIndex:=0;
end;
begin
Result:=mrCancel;
if KeyMappingEditForm<>nil then exit;
KeyMappingEditForm:=TKeyMappingEditForm.Create(nil);
with KeyMappingEditForm do
try
KeyCommandRelationList:=AKeyCommandRelationList;
KeyIndex:=Index;
Caption:=srkmEditKeys;
with KeyCommandRelationList.Relations[Index] do
begin
CommandLabel.Caption:=srkmCommand+' "'+LocalizedName+'"';
if (ShortcutA.Key1<>VK_UNKNOWN) then
begin
KeyCtrlCheckBox[0].Checked:=ssCtrl in ShortcutA.Shift1;
KeyAltCheckBox[0].Checked:=ssAlt in ShortcutA.Shift1;
KeyShiftCheckBox[0].Checked:=ssShift in ShortcutA.Shift1;
InitComboBox(KeyComboBox[0],ShortcutA.Key1);
end;
if (ShortcutA.Key2<>VK_UNKNOWN) then
begin
KeyCtrlCheckBox[1].Checked:=ssCtrl in ShortcutA.Shift2;
KeyAltCheckBox[1].Checked:=ssAlt in ShortcutA.Shift2;
KeyShiftCheckBox[1].Checked:=ssShift in ShortcutA.Shift2;
InitComboBox(KeyComboBox[1],ShortcutA.Key2);
end;
if (ShortcutB.Key1<>VK_UNKNOWN) then
begin
KeyCtrlCheckBox[2].Checked:=ssCtrl in ShortcutB.Shift1;
KeyAltCheckBox[2].Checked:=ssAlt in ShortcutB.Shift1;
KeyShiftCheckBox[2].Checked:=ssShift in ShortcutB.Shift1;
InitComboBox(KeyComboBox[2],ShortcutB.Key1);
end;
if (ShortcutB.Key2<>VK_UNKNOWN) then
begin
KeyCtrlCheckBox[3].Checked:=ssCtrl in ShortcutB.Shift2;
KeyAltCheckBox[3].Checked:=ssAlt in ShortcutB.Shift2;
KeyShiftCheckBox[3].Checked:=ssShift in ShortcutB.Shift2;
InitComboBox(KeyComboBox[3],ShortcutB.Key2);
end;
end;
Result:=ShowModal;
finally
Free;
KeyMappingEditForm:=nil;
end;
end;
function EditorCommandToDescriptionString(cmd: word): String; function EditorCommandToDescriptionString(cmd: word): String;
begin begin
case cmd of case cmd of
@ -1660,26 +1441,6 @@ begin
end; end;
end; end;
function ShowKeyMappingGrabForm(
AKeyCommandRelationList: TKeyCommandRelationList; out Key: TIDEShortCut
): TModalResult;
begin
Result:=mrCancel;
if KeyMappingEditForm<>nil then exit;
KeyMappingEditForm:=TKeyMappingEditForm.Create(nil);
with KeyMappingEditForm do begin
try
KeyCommandRelationList:=AKeyCommandRelationList;
KeyIndex:=-1;
Mode:=kmefmGrab;
Result:=ShowModal;
Key:=NewKeyA;
finally
FreeThenNil(KeyMappingEditForm);
end;
end;
end;
function FindKeymapConflicts(Keymap: TKeyCommandRelationList; function FindKeymapConflicts(Keymap: TKeyCommandRelationList;
Protocol: TStrings; out Index1,Index2:integer):integer; Protocol: TStrings; out Index1,Index2:integer):integer;
// 0 = ok, no errors // 0 = ok, no errors
@ -1871,449 +1632,6 @@ begin
Result := Result + ', ' + KeyAndShiftStateToEditorKeyString(Key.Key2, Key.Shift2); Result := Result + ', ' + KeyAndShiftStateToEditorKeyString(Key.Key2, Key.Shift2);
end; end;
{ TKeyMappingEditForm }
constructor TKeyMappingEditForm.Create(TheOwner:TComponent);
var
a, j, k, n: word;
s: string;
begin
inherited Create(TheOwner);
NewKeyA:=CleanIDEShortCut;
NewKeyB:=CleanIDEShortCut;
if LazarusResources.Find(ClassName)=nil then
begin
SetBounds((Screen.Width-432) div 2, (Screen.Height-310) div 2, 432, 340);
Caption := srkmEditForCmd;
OkButton := TButton.Create(Self);
with OkButton do begin
Name := 'OkButton';
Parent := Self;
Caption := 'Ok';
Left := 15;
Top := Self.ClientHeight-Height-15;
Width := 80;
OnClick := @OkButtonClick;
end;
CancelButton := TButton.Create(Self);
with CancelButton do begin
Name := 'CancelButton';
Parent := Self;
Caption := dlgCancel;
Left := 125;
Top := OkButton.Top;
Width := OkButton.Width;
OnClick := @CancelButtonClick;
end;
CommandLabel := TLabel.Create(Self);
with CommandLabel do begin
Name := 'CommandLabel';
Parent := Self;
Caption := srkmCommand;
Left := 5;
Top := 5;
Width := Self.ClientWidth-Left-Left;
Height := 20;
end;
for j := 0 to 1 do // Create the key groups
begin
KeyGroupBox[j] := TGroupBox.Create(Self);
with KeyGroupBox[j] do begin
Name := 'KeyGroupBox' + IntToStr(j);
Parent := Self;
Left := 5;
if (j=0) then begin
Top := CommandLabel.Top + CommandLabel.Height+8;
Caption := srkmKey
end else begin
Top := KeyGroupBox[0].Top + KeyGroupBox[0].Height+8;
Caption := srkmAlternKey;
end;
Width := Self.ClientWidth-Left-Left;
Height := 110;
end;
for k := 0 to 1 do // create the components for each group
begin
n := j*2+k;
KeyCtrlCheckBox[n] := TCheckBox.Create(Self);
with KeyCtrlCheckBox[n] do begin
Name := 'KeyCtrlCheckBox' + IntToStr(n);
Parent := KeyGroupBox[j];
Caption := srkm_Ctrl;
Left := 5 + (k * (TGroupBox(Parent).Width div 2));
Top := 2;
Width := 55;
Height := 20;
end;
KeyAltCheckBox[n] := TCheckBox.Create(Self);
with KeyAltCheckBox[n] do begin
Name := 'KeyAltCheckBox' + IntToStr(n);
Parent := KeyGroupBox[j];
Caption := srkm_Alt;
Left := KeyCtrlCheckBox[n].Left + KeyCtrlCheckBox[n].Width+10;
Top := KeyCtrlCheckBox[n].Top;
Height := 20;
Width := KeyCtrlCheckBox[n].Width;
end;
KeyShiftCheckBox[n] := TCheckBox.Create(Self);
with KeyShiftCheckBox[n] do begin
Name := 'KeyShiftCheckBox' + IntToStr(n);
Parent := KeyGroupBox[j];
Caption := srVK_SHIFT;
Left := KeyAltCheckBox[n].Left + KeyAltCheckBox[n].Width+10;
Top := KeyCtrlCheckBox[n].Top;
Height := 20;
Width := KeyCtrlCheckBox[n].Width;
end;
KeyComboBox[n] := TComboBox.Create(Self);
with KeyComboBox[n] do begin
Name := 'KeyComboBox' + IntToStr(n);
Parent := KeyGroupBox[j];
Left := KeyCtrlCheckBox[n].Left;
Top := KeyCtrlCheckBox[n].Top + KeyCtrlCheckBox[n].Height+5;
Width := 190;
Items.BeginUpdate;
Items.Add(lisNone2);
for a := 1 to 145 do
begin
s := KeyAndShiftStateToEditorKeyString(a, []);
if not EditorKeyStringIsIrregular(s) then
Items.Add(s);
end;
Items.EndUpdate;
ItemIndex := 0;
end;
KeyGrabButton[n] := TButton.Create(Self);
with KeyGrabButton[n] do begin
Parent := KeyGroupBox[j];
Left := KeyCtrlCheckBox[n].Left;
Top := KeyComboBox[n].Top+KeyComboBox[n].Height+5;
Width := KeyComboBox[n].Width;
Height := 25;
if k=0 then
Caption := srkmGrabKey
else
Caption := srkmGrabSecondKey;
Name := 'KeyGrabButton' + IntToStr(n);
Tag := n;
OnClick := @KeyGrabButtonClick;
end;
end; // for k
end; // for j
end;
GrabbingKey := 0;
end;
procedure TKeyMappingEditForm.SetupFindView;
begin
KeyGroupBox[1].Visible:=false;
CommandLabel.Caption:='Choose a key to find';
end;
procedure TKeyMappingEditForm.CheckEditModeInput;
var
CurRelation: TKeyCommandRelation;
begin
// set defaults
NewKeyA:=CleanIDEShortCut;
NewKeyB:=CleanIDEShortCut;
//debugln('TKeyMappingEditForm.OkButtonClick A ShortcutA=',KeyAndShiftStateToEditorKeyString(NewKeyA),' ShortcutB=',KeyAndShiftStateToEditorKeyString(NewKeyB));
// get old relation
CurRelation:=KeyCommandRelationList.Relations[KeyIndex];
// get settings for key1
NewKeyA.Key1:=EditorKeyStringToVKCode(KeyComboBox[0].Text);
if NewKeyA.Key1<>VK_UNKNOWN then
begin
if KeyCtrlCheckBox[0].Checked then include(NewKeyA.Shift1,ssCtrl);
if KeyAltCheckBox[0].Checked then include(NewKeyA.Shift1,ssAlt);
if KeyShiftCheckBox[0].Checked then include(NewKeyA.Shift1,ssShift);
NewKeyA.Key2:=EditorKeyStringToVKCode(KeyComboBox[1].Text);
if NewKeyA.Key2<>VK_UNKNOWN then
begin
if KeyCtrlCheckBox[1].Checked then include(NewKeyA.Shift2,ssCtrl);
if KeyAltCheckBox[1].Checked then include(NewKeyA.Shift2,ssAlt);
if KeyShiftCheckBox[1].Checked then include(NewKeyA.Shift2,ssShift);
end;
end;
if not ResolveConflicts(NewKeyA,
CurRelation.Category.Scope) then
begin
debugln('TKeyMappingEditForm.OkButtonClick ResolveConflicts failed for key1');
exit;
end;
//debugln('TKeyMappingEditForm.OkButtonClick B ShortcutA=',KeyAndShiftStateToEditorKeyString(NewKeyA),' ShortcutB=',KeyAndShiftStateToEditorKeyString(NewKeyB));
// get settings for key2
NewKeyB.Key1:=EditorKeyStringToVKCode(KeyComboBox[2].Text);
//debugln('TKeyMappingEditForm.OkButtonClick B2 ShortcutA=',KeyAndShiftStateToEditorKeyString(NewKeyA),' ShortcutB=',KeyAndShiftStateToEditorKeyString(NewKeyB),' ',Key2KeyComboBox.Text);
if NewKeyB.Key1<>VK_UNKNOWN then
begin
if KeyCtrlCheckBox[2].Checked then include(NewKeyB.Shift1,ssCtrl);
if KeyAltCheckBox[2].Checked then include(NewKeyB.Shift1,ssAlt);
if KeyShiftCheckBox[2].Checked then include(NewKeyB.Shift1,ssShift);
NewKeyB.Key2:=EditorKeyStringToVKCode(KeyComboBox[3].Text);
if NewKeyB.Key2<>VK_UNKNOWN then
begin
if KeyCtrlCheckBox[3].Checked then include(NewKeyB.Shift2,ssCtrl);
if KeyAltCheckBox[3].Checked then include(NewKeyB.Shift2,ssAlt);
if KeyShiftCheckBox[3].Checked then include(NewKeyB.Shift2,ssShift);
end;
end;
if (NewKeyA.Key1=NewKeyB.Key1) and (NewKeyA.Shift1=NewKeyB.Shift1) and
(NewKeyA.Key2=NewKeyB.Key2) and (NewKeyA.Shift2=NewKeyB.Shift2) then
begin
NewKeyB.Key1:=VK_UNKNOWN;
NewKeyB.Shift1:=[];
NewKeyB.Key2:=VK_UNKNOWN;
NewKeyB.Shift2:=[];
end
else if not ResolveConflicts(NewKeyB,CurRelation.Category.Scope)
then begin
debugln('TKeyMappingEditForm.OkButtonClick ResolveConflicts failed for key1');
exit;
end;
//debugln('TKeyMappingEditForm.OkButtonClick C ShortcutA=',KeyAndShiftStateToEditorKeyString(NewKeyA),' ShortcutB=',KeyAndShiftStateToEditorKeyString(NewKeyB));
if NewKeyA.Key1=VK_UNKNOWN then
begin
NewKeyA:=NewKeyB;
NewKeyB.Key1:=VK_UNKNOWN;
NewKeyB.Shift1:=[];
NewKeyB.Key2:=VK_UNKNOWN;
NewKeyB.Shift2:=[];
end;
//debugln('TKeyMappingEditForm.OkButtonClick D ShortcutA=',KeyAndShiftStateToEditorKeyString(NewKeyA),' ShortcutB=',KeyAndShiftStateToEditorKeyString(NewKeyB));
CurRelation.ShortcutA:=NewKeyA;
CurRelation.ShortcutB:=NewKeyB;
//debugln('TKeyMappingEditForm.OkButtonClick B ShortcutA=',KeyAndShiftStateToEditorKeyString(NewKeyA),' ShortcutB=',KeyAndShiftStateToEditorKeyString(NewKeyB));
ModalResult:=mrOk;
end;
procedure TKeyMappingEditForm.CheckGrabModeInput;
begin
// set defaults
NewKeyA:=CleanIDEShortCut;
//debugln('TKeyMappingEditForm.OkButtonClick A ShortcutA=',KeyAndShiftStateToEditorKeyString(NewKeyA),' ShortcutB=',KeyAndShiftStateToEditorKeyString(NewKeyB));
// get settings for key1
NewKeyA.Key1:=EditorKeyStringToVKCode(KeyComboBox[0].Text);
if NewKeyA.Key1<>VK_UNKNOWN then
begin
if KeyCtrlCheckBox[0].Checked then include(NewKeyA.Shift1,ssCtrl);
if KeyAltCheckBox[0].Checked then include(NewKeyA.Shift1,ssAlt);
if KeyShiftCheckBox[0].Checked then include(NewKeyA.Shift1,ssShift);
NewKeyA.Key2:=EditorKeyStringToVKCode(KeyComboBox[1].Text);
if NewKeyA.Key2<>VK_UNKNOWN then
begin
if KeyCtrlCheckBox[1].Checked then include(NewKeyA.Shift2,ssCtrl);
if KeyAltCheckBox[1].Checked then include(NewKeyA.Shift2,ssAlt);
if KeyShiftCheckBox[1].Checked then include(NewKeyA.Shift2,ssShift);
end;
end;
if NewKeyA.Key1=VK_UNKNOWN then
begin
NewKeyA:=NewKeyB;
NewKeyB.Key1:=VK_UNKNOWN;
NewKeyB.Shift1:=[];
NewKeyB.Key2:=VK_UNKNOWN;
NewKeyB.Shift2:=[];
end;
//debugln('TKeyMappingEditForm.OkButtonClick D ShortcutA=',KeyAndShiftStateToEditorKeyString(NewKeyA),' ShortcutB=',KeyAndShiftStateToEditorKeyString(NewKeyB));
ModalResult:=mrOk;
end;
procedure TKeyMappingEditForm.OkButtonClick(Sender:TObject);
begin
if Mode=kmefmGrab then
CheckGrabModeInput
else
CheckEditModeInput;
end;
procedure TKeyMappingEditForm.CancelButtonClick(Sender:TObject);
begin
ModalResult:=mrCancel;
end;
procedure TKeyMappingEditForm.KeyGrabButtonClick(Sender: TObject);
begin
ActivateGrabbing(TButton(Sender).Tag+1);
end;
procedure TKeyMappingEditForm.DeactivateGrabbing;
var i: integer;
begin
KeyPreview:=false;
if GrabbingKey=0 then exit;
// enable all components
for i:=0 to ComponentCount-1 do
begin
if (Components[i] is TWinControl) then
TWinControl(Components[i]).Enabled:=true;
end;
KeyGrabButton[GrabbingKey-1].Caption:=srkmGrabKey;
GrabbingKey:=0;
end;
procedure TKeyMappingEditForm.SetComboBox(AComboBox: TComboBox;
const AValue: string);
var i: integer;
begin
i:=AComboBox.Items.IndexOf(AValue);
if i>=0 then
AComboBox.ItemIndex:=i
else
begin
AComboBox.Items.Add(AValue);
AComboBox.ItemIndex:=AComboBox.Items.IndexOf(AValue);
end;
end;
function TKeyMappingEditForm.ResolveConflicts(Key: TIDEShortCut;
Scope: TIDECommandScope): boolean;
type
TConflictType = (ctNone,ctConflictKeyA,ctConflictKeyB);
var
ConflictRelation: TKeyCommandRelation;
ConflictName: String;
CurRelation: TKeyCommandRelation;
CurName: String;
j: integer;
conflictType: TConflictType;
begin
// search for conflict
CurRelation:=KeyCommandRelationList.Relations[KeyIndex];
if Key.Key1=VK_UNKNOWN then
begin
Result:=true;
exit;
end;
//Try to find an IDE command that conflicts
for j:=0 to KeyCommandRelationList.RelationCount-1 do begin
conflictType:=ctNone;
ConflictRelation:=KeyCommandRelationList.Relations[j];
with ConflictRelation do
begin
if (j=KeyIndex) then continue;
if not Category.ScopeIntersects(Scope) then continue;
if ((Key.Key1=ShortcutA.Key1) and (Key.Shift1=ShortcutA.Shift1))
and (((Key.Key2=ShortcutA.Key2) and (Key.Shift2=ShortcutA.Shift2))
or (Key.Key2=VK_UNKNOWN) or (ShortcutA.Key2=VK_UNKNOWN))
then begin
conflictType:=ctConflictKeyA; // ShortcutA bites
end
else if ((Key.Key1=ShortcutB.Key1) and (Key.Shift1=ShortcutB.Shift1))
and (((Key.Key2=ShortcutB.Key2) and (Key.Shift2=ShortcutB.Shift2))
or (Key.Key2<>VK_UNKNOWN) or (ShortcutB.Key2=VK_UNKNOWN))
then begin
conflictType:=ctConflictKeyB; // ShortcutB bites
end;
end;
if (conflictType<>ctNone) then begin
CurName:=CurRelation.GetCategoryAndName;
ConflictName:=ConflictRelation.GetCategoryAndName;
if conflictType=ctConflictKeyA then
ConflictName:=ConflictName
+' ('+KeyAndShiftStateToEditorKeyString(ConflictRelation.ShortcutA)
else
ConflictName:=ConflictName
+' ('+KeyAndShiftStateToEditorKeyString(ConflictRelation.ShortcutB);
if MessageDlg('Conflict found',
'The key '+KeyAndShiftStateToEditorKeyString(Key)+#13+
'is already assigned to '+ConflictName+'.'#13+#13+
'Remove the old assignment and assign the key to the new function'#13+
CurName+'?', mtConfirmation,[mbOk,mbCancel],0) <> mrOk then
begin
Result:=false;
exit;
end;
if (conflictType=ctConflictKeyA) then
ConflictRelation.ShortcutA:=ConflictRelation.ShortcutB;
ConflictRelation.ClearShortcutB;
end;
end;
Result:=true;
end;
procedure TKeyMappingEditForm.SetMode(const AValue: TKMEditFormMode);
begin
if FMode=AValue then exit;
FMode:=AValue;
if FMode=kmefmGrab then SetupFindView;
end;
procedure TKeyMappingEditForm.ActivateGrabbing(AGrabbingKey: integer);
var i: integer;
begin
if GrabbingKey>0 then exit;
GrabbingKey:=AGrabbingKey;
if GrabbingKey=0 then exit;
KeyPreview:=true;
// disable all components
for i:=0 to ComponentCount-1 do
begin
if (Components[i] is TWinControl) then
begin
if (Components[i]<>KeyGrabButton[GrabbingKey-1]) and
(Components[i]<>KeyGroupBox[(GrabbingKey-1) div 2]) then
TWinControl(Components[i]).Enabled:=false;
end;
end;
KeyGrabButton[GrabbingKey-1].Caption:=srkmPressKey;
end;
procedure TKeyMappingEditForm.KeyDown(var Key: Word; Shift: TShiftState);
begin
debugln(['TKeyMappingEditForm.FormKeyUp Sender=',Classname
,' Key=',Key,' Shift=',dbgs(Shift),' AsString=',KeyAndShiftStateToEditorKeyString(Key,[]),
'']);
if (GrabbingKey>0)
and not (Key in [VK_CONTROL, VK_LCONTROL, VK_RCONTROL,
VK_SHIFT, VK_LSHIFT, VK_RSHIFT,
VK_MENU, VK_LMENU, VK_RMENU]) then
begin
KeyCtrlCheckBox[GrabbingKey-1].Checked:=(ssCtrl in Shift);
KeyShiftCheckBox[GrabbingKey-1].Checked:=(ssShift in Shift);
KeyAltCheckBox[GrabbingKey-1].Checked:=(ssAlt in Shift);
SetComboBox(KeyComboBox[GrabbingKey-1], KeyAndShiftStateToEditorKeyString(Key,[]));
Key:=0;
DeactivateGrabbing;
end;
inherited;
end;
{ TKeyCommandRelation } { TKeyCommandRelation }
procedure TKeyCommandRelation.SetShortcutA(const AValue: TIDEShortCut); procedure TKeyCommandRelation.SetShortcutA(const AValue: TIDEShortCut);
@ -3369,241 +2687,6 @@ end;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
{ TCustomShortCutGrabBox }
procedure TCustomShortCutGrabBox.SetKey(const AValue: Word);
begin
if FKey=AValue then exit;
FKey:=AValue;
FKeyComboBox.Text:=KeyAndShiftStateToEditorKeyString(Key,[]);
end;
procedure TCustomShortCutGrabBox.OnGrabButtonClick(Sender: TObject);
begin
FGrabForm:=TForm.Create(Self);
FGrabForm.KeyPreview:=true;
FGrabForm.Position:=poDesktopCenter;
FGrabForm.OnKeyDown:=@OnGrabFormKeyDown;
FGrabForm.Caption:='Press a key ...';
with TLabel.Create(Self) do begin
Caption:='Press a key ...';
BorderSpacing.Around:=25;
Parent:=FGrabForm;
end;
FGrabForm.AutoSize:=true;
FGrabForm.ShowModal;
FreeThenNil(FGrabForm);
end;
procedure TCustomShortCutGrabBox.OnShitCheckBoxClick(Sender: TObject);
var
s: TShiftStateEnum;
begin
for s:=Low(TShiftStateEnum) to High(TShiftStateEnum) do
if FCheckBoxes[s]=Sender then
if FCheckBoxes[s].Checked then
Include(FShiftState,s)
else
Exclude(FShiftState,s);
end;
procedure TCustomShortCutGrabBox.OnGrabFormKeyDown(Sender: TObject;
var AKey: Word; AShift: TShiftState);
begin
//DebugLn(['TCustomShortCutGrabBox.OnGrabFormKeyDown ',AKey,' ',dbgs(AShift)]);
if not (AKey in [VK_CONTROL, VK_LCONTROL, VK_RCONTROL,
VK_SHIFT, VK_LSHIFT, VK_RSHIFT,
VK_MENU, VK_LMENU, VK_RMENU,
VK_UNKNOWN, VK_UNDEFINED])
then begin
Key:=AKey;
ShiftState:=AShift;
FGrabForm.ModalResult:=mrOk;
end;
end;
procedure TCustomShortCutGrabBox.OnKeyComboboxEditingDone(Sender: TObject);
begin
Key:=EditorKeyStringToVKCode(KeyComboBox.Text);
end;
function TCustomShortCutGrabBox.GetShiftCheckBox(Shift: TShiftStateEnum
): TCheckBox;
begin
Result:=FCheckBoxes[Shift];
end;
procedure TCustomShortCutGrabBox.SetAllowedShifts(const AValue: TShiftState);
begin
if FAllowedShifts=AValue then exit;
FAllowedShifts:=AValue;
ShiftState:=ShiftState*FAllowedShifts;
end;
procedure TCustomShortCutGrabBox.SetShiftButtons(const AValue: TShiftState);
begin
if FShiftButtons=AValue then exit;
FShiftButtons:=AValue;
UpdateShiftButons;
end;
procedure TCustomShortCutGrabBox.SetShiftState(const AValue: TShiftState);
var
s: TShiftStateEnum;
begin
if FShiftState=AValue then exit;
FShiftState:=AValue;
for s:=low(TShiftStateEnum) to High(TShiftStateEnum) do
if FCheckBoxes[s]<>nil then
FCheckBoxes[s].Checked:=s in FShiftState;
end;
procedure TCustomShortCutGrabBox.Loaded;
begin
inherited Loaded;
UpdateShiftButons;
end;
procedure TCustomShortCutGrabBox.UpdateShiftButons;
var
s: TShiftStateEnum;
LastCheckBox: TCheckBox;
begin
if [csLoading,csDestroying]*ComponentState<>[] then exit;
LastCheckBox:=nil;
DisableAlign;
try
for s:=low(TShiftStateEnum) to High(TShiftStateEnum) do begin
if s in FShiftButtons then begin
if FCheckBoxes[s]=nil then begin
FCheckBoxes[s]:=TCheckBox.Create(Self);
with FCheckBoxes[s] do begin
Name:='CheckBox'+ShiftToStr(s);
Caption:=ShiftToStr(s);
AutoSize:=true;
Checked:=s in FShiftState;
if LastCheckBox<>nil then
AnchorToNeighbour(akLeft,6,LastCheckBox)
else
AnchorParallel(akLeft,0,Self);
AnchorParallel(akTop,0,Self);
AnchorParallel(akBottom,0,Self);
Parent:=Self;
OnClick:=@OnShitCheckBoxClick;
end;
end;
LastCheckBox:=FCheckBoxes[s];
end else begin
FreeThenNil(FCheckBoxes[s]);
end;
end;
if LastCheckBox<>nil then
FKeyComboBox.AnchorToNeighbour(akLeft,6,LastCheckBox)
else
FKeyComboBox.AnchorParallel(akLeft,0,Self);
finally
EnableAlign;
end;
end;
procedure TCustomShortCutGrabBox.Notification(AComponent: TComponent;
Operation: TOperation);
var
s: TShiftStateEnum;
begin
inherited Notification(AComponent, Operation);
if Operation=opRemove then begin
if AComponent=FGrabButton then
FGrabButton:=nil;
if AComponent=FKeyComboBox then
FKeyComboBox:=nil;
if AComponent=FGrabForm then
FGrabForm:=nil;
for s:=Low(TShiftStateEnum) to High(TShiftStateEnum) do
if FCheckBoxes[s]=AComponent then begin
FCheckBoxes[s]:=nil;
Exclude(FShiftButtons,s);
end;
end;
end;
function TCustomShortCutGrabBox.ShiftToStr(s: TShiftStateEnum): string;
begin
case s of
ssShift: Result:='Shift';
ssAlt: Result:='Alt';
ssCtrl: Result:='Ctrl';
ssMeta: Result:='Meta';
ssSuper: Result:='Super';
ssHyper: {$IFDEF Darwin}
Result:='Cmd';
{$ELSE}
Result:='Hyper';
{$ENDIF}
ssAltGr: Result:='AltGr';
ssCaps: Result:='Caps';
ssNum: Result:='Numlock';
ssScroll: Result:='Scroll';
else Result:='Modifier'+IntToStr(ord(s));
end;
end;
constructor TCustomShortCutGrabBox.Create(TheOwner: TComponent);
var
i: Integer;
s: String;
begin
inherited Create(TheOwner);
FAllowedShifts:=[ssShift, ssAlt, ssCtrl,
ssMeta, ssSuper, ssHyper, ssAltGr,
ssCaps, ssNum, ssScroll];
FGrabButton:=TButton.Create(Self);
with FGrabButton do begin
Name:='GrabButton';
Caption:='Grab key';
Align:=alRight;
AutoSize:=true;
Parent:=Self;
OnClick:=@OnGrabButtonClick;
end;
FKeyComboBox:=TComboBox.Create(Self);
with FKeyComboBox do begin
Name:='FKeyComboBox';
AutoSize:=true;
Items.BeginUpdate;
for i:=1 to 145 do begin
s := KeyAndShiftStateToEditorKeyString(i, []);
if not EditorKeyStringIsIrregular(s) then
Items.Add(s);
end;
Items.EndUpdate;
OnEditingDone:=@OnKeyComboboxEditingDone;
Parent:=Self;
AnchorToNeighbour(akRight,6,FGrabButton);
AnchorVerticalCenterTo(FGrabButton);
end;
ShiftButtons:=GetDefaultShiftButtons;
ShiftState:=[];
Key:=VK_UNKNOWN;
KeyComboBox.Text:=KeyAndShiftStateToEditorKeyString(Key,[]);
end;
function TCustomShortCutGrabBox.GetDefaultShiftButtons: TShiftState;
begin
{$IFDEF Darwin}
Result:=[ssCtrl,ssShift,ssAlt,ssHyper];
{$ELSE}
Result:=[ssCtrl,ssShift,ssAlt];
{$ENDIF}
end;
initialization
KeyMappingEditForm:=nil;
finalization finalization
VirtualKeyStrings.Free; VirtualKeyStrings.Free;
VirtualKeyStrings:=nil; VirtualKeyStrings:=nil;

71
ide/keymapshortcutdlg.lfm Normal file
View File

@ -0,0 +1,71 @@
object ShortCutDialog: TShortCutDialog
Left = 290
Height = 257
Top = 189
Width = 545
Caption = 'ShortCutDialog'
ClientHeight = 257
ClientWidth = 545
OnCreate = FormCreate
LCLVersion = '0.9.25'
object BtnPanel: TPanel
Height = 41
Top = 216
Width = 545
Align = alBottom
AutoSize = True
BevelOuter = bvNone
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 6
ChildSizing.VerticalSpacing = 6
ClientHeight = 41
ClientWidth = 545
TabOrder = 0
object CancelButton: TButton
Left = 441
Height = 29
Top = 6
Width = 98
Align = alRight
AutoSize = True
Caption = 'CancelButton'
Constraints.MinWidth = 75
ModalResult = 2
OnClick = CancelButtonClick
TabOrder = 0
end
object OkButton: TButton
Left = 360
Height = 29
Top = 6
Width = 75
Align = alRight
AutoSize = True
Caption = 'OkButton'
Constraints.MinWidth = 75
OnClick = OkButtonClick
TabOrder = 1
end
end
object PrimaryGroupBox: TGroupBox
Left = 6
Height = 93
Top = 6
Width = 533
Align = alTop
BorderSpacing.Around = 6
Caption = 'PrimaryGroupBox'
TabOrder = 1
end
object SecondaryGroupBox: TGroupBox
Left = 6
Height = 105
Top = 105
Width = 533
Align = alTop
BorderSpacing.Around = 6
Caption = 'SecondaryGroupBox'
TabOrder = 2
end
end

24
ide/keymapshortcutdlg.lrs Normal file
View File

@ -0,0 +1,24 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TShortCutDialog','FORMDATA',[
'TPF0'#15'TShortCutDialog'#14'ShortCutDialog'#4'Left'#3'"'#1#6'Height'#3#1#1#3
+'Top'#3#189#0#5'Width'#3'!'#2#7'Caption'#6#14'ShortCutDialog'#12'ClientHeigh'
+'t'#3#1#1#11'ClientWidth'#3'!'#2#8'OnCreate'#7#10'FormCreate'#10'LCLVersion'
+#6#6'0.9.25'#0#6'TPanel'#8'BtnPanel'#6'Height'#2')'#3'Top'#3#216#0#5'Width'#3
+'!'#2#5'Align'#7#8'alBottom'#8'AutoSize'#9#10'BevelOuter'#7#6'bvNone'#28'Chi'
+'ldSizing.LeftRightSpacing'#2#6#28'ChildSizing.TopBottomSpacing'#2#6#29'Chil'
+'dSizing.HorizontalSpacing'#2#6#27'ChildSizing.VerticalSpacing'#2#6#12'Clien'
+'tHeight'#2')'#11'ClientWidth'#3'!'#2#8'TabOrder'#2#0#0#7'TButton'#12'Cancel'
+'Button'#4'Left'#3#185#1#6'Height'#2#29#3'Top'#2#6#5'Width'#2'b'#5'Align'#7#7
+'alRight'#8'AutoSize'#9#7'Caption'#6#12'CancelButton'#20'Constraints.MinWidt'
+'h'#2'K'#11'ModalResult'#2#2#7'OnClick'#7#17'CancelButtonClick'#8'TabOrder'#2
+#0#0#0#7'TButton'#8'OkButton'#4'Left'#3'h'#1#6'Height'#2#29#3'Top'#2#6#5'Wid'
+'th'#2'K'#5'Align'#7#7'alRight'#8'AutoSize'#9#7'Caption'#6#8'OkButton'#20'Co'
+'nstraints.MinWidth'#2'K'#7'OnClick'#7#13'OkButtonClick'#8'TabOrder'#2#1#0#0
+#0#9'TGroupBox'#15'PrimaryGroupBox'#4'Left'#2#6#6'Height'#2']'#3'Top'#2#6#5
+'Width'#3#21#2#5'Align'#7#5'alTop'#20'BorderSpacing.Around'#2#6#7'Caption'#6
+#15'PrimaryGroupBox'#8'TabOrder'#2#1#0#0#9'TGroupBox'#17'SecondaryGroupBox'#4
+'Left'#2#6#6'Height'#2'i'#3'Top'#2'i'#5'Width'#3#21#2#5'Align'#7#5'alTop'#20
+'BorderSpacing.Around'#2#6#7'Caption'#6#17'SecondaryGroupBox'#8'TabOrder'#2#2
+#0#0#0
]);

750
ide/keymapshortcutdlg.pas Normal file
View File

@ -0,0 +1,750 @@
{
***************************************************************************
* *
* This source is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This code is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* A copy of the GNU General Public License is available on the World *
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
* obtain it by writing to the Free Software Foundation, *
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
***************************************************************************
Author: Mattias Gaertner
Abstract:
TShortCutGrabBox - a control to edit a shortcut
TShortCutDialog - a dialog to edit ide shortcuts
}
unit KeyMapShortCutDlg;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, LCLProc, Forms, Controls, Graphics, Dialogs,
ExtCtrls, StdCtrls, LCLType,
IDECommands, IDEWindowIntf,
KeyMapping, LazarusIDEStrConsts;
type
{ TCustomShortCutGrabBox }
TCustomShortCutGrabBox = class(TCustomPanel)
private
FAllowedShifts: TShiftState;
FGrabButton: TButton;
FKey: Word;
FKeyComboBox: TComboBox;
FShiftButtons: TShiftState;
FShiftState: TShiftState;
FCheckBoxes: array[TShiftStateEnum] of TCheckBox;
FGrabForm: TForm;
function GetShiftCheckBox(Shift: TShiftStateEnum): TCheckBox;
procedure SetAllowedShifts(const AValue: TShiftState);
procedure SetKey(const AValue: Word);
procedure SetShiftButtons(const AValue: TShiftState);
procedure SetShiftState(const AValue: TShiftState);
procedure OnGrabButtonClick(Sender: TObject);
procedure OnShitCheckBoxClick(Sender: TObject);
procedure OnGrabFormKeyDown(Sender: TObject; var AKey: Word;
AShift: TShiftState);
procedure OnKeyComboboxEditingDone(Sender: TObject);
protected
procedure Loaded; override;
procedure UpdateShiftButons;
procedure Notification(AComponent: TComponent; Operation: TOperation);
override;
function ShiftToStr(s: TShiftStateEnum): string;
public
constructor Create(TheOwner: TComponent); override;
function GetDefaultShiftButtons: TShiftState;
property ShiftState: TShiftState read FShiftState write SetShiftState;
property Key: Word read FKey write SetKey;
property ShiftButtons: TShiftState read FShiftButtons write SetShiftButtons;
property AllowedShifts: TShiftState read FAllowedShifts write SetAllowedShifts;
property KeyComboBox: TComboBox read FKeyComboBox;
property GrabButton: TButton read FGrabButton;
property ShiftCheckBox[Shift: TShiftStateEnum]: TCheckBox read GetShiftCheckBox;
end;
{ TShortCutGrabBox }
TShortCutGrabBox = class(TCustomShortCutGrabBox)
published
property Align;
property Alignment;
property AllowedShifts;
property Anchors;
property AutoSize;
property BevelInner;
property BevelOuter;
property BevelWidth;
property BorderSpacing;
property BorderStyle;
property BorderWidth;
property Caption;
property ChildSizing;
property ClientHeight;
property ClientWidth;
property Color;
property Constraints;
property DockSite;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Font;
property FullRepaint;
property Key;
property OnClick;
property OnDblClick;
property OnDockDrop;
property OnDockOver;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnGetDockCaption;
property OnGetSiteInfo;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnStartDock;
property OnStartDrag;
property OnUnDock;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShiftButtons;
property ShiftState;
property ShowHint;
property TabOrder;
property TabStop;
property UseDockManager default True;
property Visible;
end;
{ TShortCutDialog }
TShortCutDialog = class(TForm)
BtnPanel: TPanel;
PrimaryGroupBox: TGroupBox;
SecondaryGroupBox: TGroupBox;
OkButton: TButton;
CancelButton: TButton;
procedure CancelButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure OkButtonClick(Sender: TObject);
private
FKeyCommandRelationList: TKeyCommandRelationList;
FPrimaryKey1Box: TShortCutGrabBox;
FPrimaryKey2Box: TShortCutGrabBox;
FRelationIndex: integer;
FSecondaryKey1Box: TShortCutGrabBox;
FSecondaryKey2Box: TShortCutGrabBox;
FShowSecondary: boolean;
FShowSequence: boolean;
function GetPrimaryShortCut: TIDEShortCut;
function GetSecondaryShortCut: TIDEShortCut;
procedure SetPrimaryShortCut(const AValue: TIDEShortCut);
procedure SetSecondaryShortCut(const AValue: TIDEShortCut);
procedure SetShowSecondary(const AValue: boolean);
procedure SetShowSequence(const AValue: boolean);
function ResolveConflicts(Key: TIDEShortCut; Scope: TIDECommandScope): boolean;
procedure UpdateCaptions;
public
procedure ClearKeys;
procedure SetRelation(AKeyCommandRelationList: TKeyCommandRelationList;
Index: integer);
property KeyCommandRelationList: TKeyCommandRelationList
read FKeyCommandRelationList write FKeyCommandRelationList;
property RelationIndex: integer read FRelationIndex write FRelationIndex;
property ShowSecondary: boolean read FShowSecondary write SetShowSecondary;
property ShowSequence: boolean read FShowSequence write SetShowSequence;
property PrimaryKey1Box: TShortCutGrabBox read FPrimaryKey1Box;
property PrimaryKey2Box: TShortCutGrabBox read FPrimaryKey2Box;
property SecondaryKey1Box: TShortCutGrabBox read FSecondaryKey1Box;
property SecondaryKey2Box: TShortCutGrabBox read FSecondaryKey2Box;
property PrimaryShortCut: TIDEShortCut read GetPrimaryShortCut write SetPrimaryShortCut;
property SecondaryShortCut: TIDEShortCut read GetSecondaryShortCut write SetSecondaryShortCut;
end;
function ShowKeyMappingEditForm(Index: integer;
AKeyCommandRelationList: TKeyCommandRelationList): TModalResult;
function ShowKeyMappingGrabForm(out Key: TIDEShortCut;
AllowSequence: boolean = false): TModalResult;
implementation
function ShowKeyMappingEditForm(Index: integer;
AKeyCommandRelationList: TKeyCommandRelationList): TModalResult;
var
ShortCutDialog: TShortCutDialog;
begin
ShortCutDialog:=TShortCutDialog.Create(nil);
try
ShortCutDialog.ShowSecondary:=true;
ShortCutDialog.ShowSequence:=true;
ShortCutDialog.SetRelation(AKeyCommandRelationList,Index);
Result:=ShortCutDialog.ShowModal;
finally
ShortCutDialog.Free;
end;
end;
function ShowKeyMappingGrabForm(out Key: TIDEShortCut;
AllowSequence: boolean): TModalResult;
var
ShortCutDialog: TShortCutDialog;
begin
ShortCutDialog:=TShortCutDialog.Create(nil);
try
ShortCutDialog.ShowSecondary:=false;
ShortCutDialog.ShowSequence:=AllowSequence;
ShortCutDialog.Caption:=lisChooseAKey;
Result:=ShortCutDialog.ShowModal;
Key:=ShortCutDialog.PrimaryShortCut;
finally
ShortCutDialog.Free;
end;
end;
{ TCustomShortCutGrabBox }
procedure TCustomShortCutGrabBox.SetKey(const AValue: Word);
var
s: String;
i: LongInt;
begin
if FKey=AValue then exit;
FKey:=AValue;
s:=KeyAndShiftStateToEditorKeyString(FKey,[]);
i:=KeyComboBox.Items.IndexOf(s);
if i>=0 then
KeyComboBox.ItemIndex:=i
else if EditorKeyStringIsIrregular(s) then begin
KeyComboBox.Items.Add(s);
KeyComboBox.ItemIndex:=KeyComboBox.Items.IndexOf(s);
end else
KeyComboBox.ItemIndex:=0;
end;
procedure TCustomShortCutGrabBox.OnGrabButtonClick(Sender: TObject);
begin
FGrabForm:=TForm.Create(Self);
FGrabForm.KeyPreview:=true;
FGrabForm.Position:=poDesktopCenter;
FGrabForm.OnKeyDown:=@OnGrabFormKeyDown;
FGrabForm.Caption:='Press a key ...';
with TLabel.Create(Self) do begin
Caption:='Press a key ...';
BorderSpacing.Around:=25;
Parent:=FGrabForm;
end;
FGrabForm.AutoSize:=true;
FGrabForm.ShowModal;
FreeAndNil(FGrabForm);
end;
procedure TCustomShortCutGrabBox.OnShitCheckBoxClick(Sender: TObject);
var
s: TShiftStateEnum;
begin
for s:=Low(TShiftStateEnum) to High(TShiftStateEnum) do
if FCheckBoxes[s]=Sender then
if FCheckBoxes[s].Checked then
Include(FShiftState,s)
else
Exclude(FShiftState,s);
end;
procedure TCustomShortCutGrabBox.OnGrabFormKeyDown(Sender: TObject;
var AKey: Word; AShift: TShiftState);
begin
//DebugLn(['TCustomShortCutGrabBox.OnGrabFormKeyDown ',AKey,' ',dbgs(AShift)]);
if not (AKey in [VK_CONTROL, VK_LCONTROL, VK_RCONTROL,
VK_SHIFT, VK_LSHIFT, VK_RSHIFT,
VK_MENU, VK_LMENU, VK_RMENU,
VK_UNKNOWN, VK_UNDEFINED])
then begin
Key:=AKey;
ShiftState:=AShift;
FGrabForm.ModalResult:=mrOk;
end;
end;
procedure TCustomShortCutGrabBox.OnKeyComboboxEditingDone(Sender: TObject);
begin
Key:=EditorKeyStringToVKCode(KeyComboBox.Text);
end;
function TCustomShortCutGrabBox.GetShiftCheckBox(Shift: TShiftStateEnum
): TCheckBox;
begin
Result:=FCheckBoxes[Shift];
end;
procedure TCustomShortCutGrabBox.SetAllowedShifts(const AValue: TShiftState);
begin
if FAllowedShifts=AValue then exit;
FAllowedShifts:=AValue;
ShiftState:=ShiftState*FAllowedShifts;
end;
procedure TCustomShortCutGrabBox.SetShiftButtons(const AValue: TShiftState);
begin
if FShiftButtons=AValue then exit;
FShiftButtons:=AValue;
UpdateShiftButons;
end;
procedure TCustomShortCutGrabBox.SetShiftState(const AValue: TShiftState);
var
s: TShiftStateEnum;
begin
if FShiftState=AValue then exit;
FShiftState:=AValue;
for s:=low(TShiftStateEnum) to High(TShiftStateEnum) do
if FCheckBoxes[s]<>nil then
FCheckBoxes[s].Checked:=s in FShiftState;
end;
procedure TCustomShortCutGrabBox.Loaded;
begin
inherited Loaded;
UpdateShiftButons;
end;
procedure TCustomShortCutGrabBox.UpdateShiftButons;
var
s: TShiftStateEnum;
LastCheckBox: TCheckBox;
begin
if [csLoading,csDestroying]*ComponentState<>[] then exit;
LastCheckBox:=nil;
DisableAlign;
try
for s:=low(TShiftStateEnum) to High(TShiftStateEnum) do begin
if s in FShiftButtons then begin
if FCheckBoxes[s]=nil then begin
FCheckBoxes[s]:=TCheckBox.Create(Self);
with FCheckBoxes[s] do begin
Name:='CheckBox'+ShiftToStr(s);
Caption:=ShiftToStr(s);
AutoSize:=true;
Checked:=s in FShiftState;
if LastCheckBox<>nil then
AnchorToNeighbour(akLeft,6,LastCheckBox)
else
AnchorParallel(akLeft,0,Self);
AnchorParallel(akTop,0,Self);
AnchorParallel(akBottom,0,Self);
Parent:=Self;
OnClick:=@OnShitCheckBoxClick;
end;
end;
LastCheckBox:=FCheckBoxes[s];
end else begin
FreeAndNil(FCheckBoxes[s]);
end;
end;
if LastCheckBox<>nil then
FKeyComboBox.AnchorToNeighbour(akLeft,6,LastCheckBox)
else
FKeyComboBox.AnchorParallel(akLeft,0,Self);
finally
EnableAlign;
end;
end;
procedure TCustomShortCutGrabBox.Notification(AComponent: TComponent;
Operation: TOperation);
var
s: TShiftStateEnum;
begin
inherited Notification(AComponent, Operation);
if Operation=opRemove then begin
if AComponent=FGrabButton then
FGrabButton:=nil;
if AComponent=FKeyComboBox then
FKeyComboBox:=nil;
if AComponent=FGrabForm then
FGrabForm:=nil;
for s:=Low(TShiftStateEnum) to High(TShiftStateEnum) do
if FCheckBoxes[s]=AComponent then begin
FCheckBoxes[s]:=nil;
Exclude(FShiftButtons,s);
end;
end;
end;
function TCustomShortCutGrabBox.ShiftToStr(s: TShiftStateEnum): string;
begin
case s of
ssShift: Result:='Shift';
ssAlt: Result:='Alt';
ssCtrl: Result:='Ctrl';
ssMeta: Result:='Meta';
ssSuper: Result:='Super';
ssHyper: {$IFDEF Darwin}
Result:='Cmd';
{$ELSE}
Result:='Hyper';
{$ENDIF}
ssAltGr: Result:='AltGr';
ssCaps: Result:='Caps';
ssNum: Result:='Numlock';
ssScroll: Result:='Scroll';
else Result:='Modifier'+IntToStr(ord(s));
end;
end;
constructor TCustomShortCutGrabBox.Create(TheOwner: TComponent);
var
i: Integer;
s: String;
begin
inherited Create(TheOwner);
FAllowedShifts:=[ssShift, ssAlt, ssCtrl,
ssMeta, ssSuper, ssHyper, ssAltGr,
ssCaps, ssNum, ssScroll];
FGrabButton:=TButton.Create(Self);
with FGrabButton do begin
Name:='GrabButton';
Caption:='Grab key';
Align:=alRight;
AutoSize:=true;
Parent:=Self;
OnClick:=@OnGrabButtonClick;
end;
FKeyComboBox:=TComboBox.Create(Self);
with FKeyComboBox do begin
Name:='FKeyComboBox';
AutoSize:=true;
Items.BeginUpdate;
for i:=1 to 145 do begin
s := KeyAndShiftStateToEditorKeyString(i, []);
if not EditorKeyStringIsIrregular(s) then
Items.Add(s);
end;
Items.EndUpdate;
OnEditingDone:=@OnKeyComboboxEditingDone;
Parent:=Self;
AnchorToNeighbour(akRight,6,FGrabButton);
AnchorVerticalCenterTo(FGrabButton);
end;
BevelOuter:=bvNone;
ShiftButtons:=GetDefaultShiftButtons;
ShiftState:=[];
Key:=VK_UNKNOWN;
KeyComboBox.Text:=KeyAndShiftStateToEditorKeyString(Key,[]);
end;
function TCustomShortCutGrabBox.GetDefaultShiftButtons: TShiftState;
begin
{$IFDEF Darwin}
Result:=[ssCtrl,ssShift,ssAlt,ssHyper];
{$ELSE}
Result:=[ssCtrl,ssShift,ssAlt];
{$ENDIF}
end;
{ TShortCutDialog }
procedure TShortCutDialog.FormCreate(Sender: TObject);
begin
Caption := srkmEditForCmd;
OkButton.Caption:=lisOkBtn;
CancelButton.Caption:=dlgCancel;
IDEDialogLayoutList.ApplyLayout(Self, 480, 480);
FShowSecondary:=true;
FShowSequence:=true;
FPrimaryKey1Box:=TShortCutGrabBox.Create(Self);
with FPrimaryKey1Box do begin
Name:='FPrimaryKey1Box';
Align:=alClient;
AutoSize:=true;
BorderSpacing.Around:=6;
Parent:=PrimaryGroupBox;
end;
FPrimaryKey2Box:=TShortCutGrabBox.Create(Self);
with FPrimaryKey2Box do begin
Name:='FPrimaryKey2Box';
Align:=alBottom;
AutoSize:=true;
BorderSpacing.Around:=6;
Parent:=PrimaryGroupBox;
end;
PrimaryGroupBox.AutoSize:=true;
FSecondaryKey1Box:=TShortCutGrabBox.Create(Self);
with FSecondaryKey1Box do begin
Name:='FSecondaryKey1Box';
Align:=alClient;
AutoSize:=true;
BorderSpacing.Around:=6;
Parent:=SecondaryGroupBox;
end;
FSecondaryKey2Box:=TShortCutGrabBox.Create(Self);
with FSecondaryKey2Box do begin
Name:='FSecondaryKey2Box';
Align:=alBottom;
AutoSize:=true;
BorderSpacing.Around:=6;
Parent:=SecondaryGroupBox;
end;
SecondaryGroupBox.AutoSize:=true;
UpdateCaptions;
ClearKeys;
end;
procedure TShortCutDialog.CancelButtonClick(Sender: TObject);
begin
IDEDialogLayoutList.SaveLayout(Self);
end;
procedure TShortCutDialog.OkButtonClick(Sender: TObject);
var
NewKeyA: TIDEShortCut;
NewKeyB: TIDEShortCut;
CurRelation: TKeyCommandRelation;
begin
IDEDialogLayoutList.SaveLayout(Self);
if KeyCommandRelationList=nil then begin
ModalResult:=mrOk;
exit;
end;
// set defaults
NewKeyA:=PrimaryShortCut;
NewKeyB:=SecondaryShortCut;
//debugln('TShortCutDialog.OkButtonClick A ShortcutA=',KeyAndShiftStateToEditorKeyString(NewKeyA),' ShortcutB=',KeyAndShiftStateToEditorKeyString(NewKeyB));
// get old relation
CurRelation:=KeyCommandRelationList.Relations[RelationIndex];
if not ResolveConflicts(NewKeyA,CurRelation.Category.Scope) then
begin
debugln('TShortCutDialog.OkButtonClick ResolveConflicts failed for key1');
exit;
end;
//debugln('TShortCutDialog.OkButtonClick B ShortcutA=',KeyAndShiftStateToEditorKeyString(NewKeyA),' ShortcutB=',KeyAndShiftStateToEditorKeyString(NewKeyB));
if (NewKeyA.Key1=NewKeyB.Key1) and (NewKeyA.Shift1=NewKeyB.Shift1) and
(NewKeyA.Key2=NewKeyB.Key2) and (NewKeyA.Shift2=NewKeyB.Shift2) then
begin
NewKeyB.Key1:=VK_UNKNOWN;
NewKeyB.Shift1:=[];
NewKeyB.Key2:=VK_UNKNOWN;
NewKeyB.Shift2:=[];
end
else if not ResolveConflicts(NewKeyB,CurRelation.Category.Scope)
then begin
debugln('TShortCutDialog.OkButtonClick ResolveConflicts failed for key1');
exit;
end;
//debugln('TShortCutDialog.OkButtonClick C ShortcutA=',KeyAndShiftStateToEditorKeyString(NewKeyA),' ShortcutB=',KeyAndShiftStateToEditorKeyString(NewKeyB));
if NewKeyA.Key1=VK_UNKNOWN then
begin
NewKeyA:=NewKeyB;
NewKeyB.Key1:=VK_UNKNOWN;
NewKeyB.Shift1:=[];
NewKeyB.Key2:=VK_UNKNOWN;
NewKeyB.Shift2:=[];
end;
//debugln('TShortCutDialog.OkButtonClick D ShortcutA=',KeyAndShiftStateToEditorKeyString(NewKeyA),' ShortcutB=',KeyAndShiftStateToEditorKeyString(NewKeyB));
CurRelation.ShortcutA:=NewKeyA;
CurRelation.ShortcutB:=NewKeyB;
//debugln('TShortCutDialog.OkButtonClick B ShortcutA=',KeyAndShiftStateToEditorKeyString(NewKeyA),' ShortcutB=',KeyAndShiftStateToEditorKeyString(NewKeyB));
ModalResult:=mrOk;
end;
procedure TShortCutDialog.SetShowSecondary(const AValue: boolean);
begin
if FShowSecondary=AValue then exit;
FShowSecondary:=AValue;
SecondaryGroupBox.Visible:=FShowSecondary;
end;
procedure TShortCutDialog.SetPrimaryShortCut(const AValue: TIDEShortCut);
var
APrimaryShortCut: TIDEShortCut;
begin
APrimaryShortCut:=GetPrimaryShortCut;
if CompareIDEShortCuts(@APrimaryShortCut,@AValue)=0 then exit;
PrimaryKey1Box.Key:=AValue.Key1;
PrimaryKey1Box.ShiftState:=AValue.Shift1;
PrimaryKey2Box.Key:=AValue.Key2;
PrimaryKey2Box.ShiftState:=AValue.Shift2;
end;
function TShortCutDialog.GetPrimaryShortCut: TIDEShortCut;
begin
Result.Key1:=PrimaryKey1Box.Key;
Result.Shift1:=PrimaryKey1Box.ShiftState;
Result.Key2:=PrimaryKey2Box.Key;
Result.Shift2:=PrimaryKey2Box.ShiftState;
end;
function TShortCutDialog.GetSecondaryShortCut: TIDEShortCut;
begin
Result.Key1:=SecondaryKey1Box.Key;
Result.Shift1:=SecondaryKey1Box.ShiftState;
Result.Key2:=SecondaryKey2Box.Key;
Result.Shift2:=SecondaryKey2Box.ShiftState;
end;
procedure TShortCutDialog.SetSecondaryShortCut(const AValue: TIDEShortCut);
var
ASecondaryShortCut: TIDEShortCut;
begin
ASecondaryShortCut:=SecondaryShortCut;
if CompareIDEShortCuts(@ASecondaryShortCut,@AValue)=0 then exit;
SecondaryKey1Box.Key:=AValue.Key1;
SecondaryKey1Box.ShiftState:=AValue.Shift1;
SecondaryKey2Box.Key:=AValue.Key2;
SecondaryKey2Box.ShiftState:=AValue.Shift2;
end;
procedure TShortCutDialog.SetShowSequence(const AValue: boolean);
begin
if FShowSequence=AValue then exit;
FShowSequence:=AValue;
FPrimaryKey2Box.Visible:=FShowSequence;
FSecondaryKey2Box.Visible:=FShowSequence;
UpdateCaptions;
end;
function TShortCutDialog.ResolveConflicts(Key: TIDEShortCut;
Scope: TIDECommandScope): boolean;
type
TConflictType = (ctNone,ctConflictKeyA,ctConflictKeyB);
var
ConflictRelation: TKeyCommandRelation;
ConflictName: String;
CurRelation: TKeyCommandRelation;
CurName: String;
j: integer;
conflictType: TConflictType;
begin
// search for conflict
CurRelation:=KeyCommandRelationList.Relations[RelationIndex];
if Key.Key1=VK_UNKNOWN then
begin
Result:=true;
exit;
end;
//Try to find an IDE command that conflicts
for j:=0 to KeyCommandRelationList.RelationCount-1 do begin
conflictType:=ctNone;
ConflictRelation:=KeyCommandRelationList.Relations[j];
with ConflictRelation do
begin
if (j=RelationIndex) then continue;
if not Category.ScopeIntersects(Scope) then continue;
if ((Key.Key1=ShortcutA.Key1) and (Key.Shift1=ShortcutA.Shift1))
and (((Key.Key2=ShortcutA.Key2) and (Key.Shift2=ShortcutA.Shift2))
or (Key.Key2=VK_UNKNOWN) or (ShortcutA.Key2=VK_UNKNOWN))
then begin
conflictType:=ctConflictKeyA; // ShortcutA bites
end
else if ((Key.Key1=ShortcutB.Key1) and (Key.Shift1=ShortcutB.Shift1))
and (((Key.Key2=ShortcutB.Key2) and (Key.Shift2=ShortcutB.Shift2))
or (Key.Key2<>VK_UNKNOWN) or (ShortcutB.Key2=VK_UNKNOWN))
then begin
conflictType:=ctConflictKeyB; // ShortcutB bites
end;
end;
if (conflictType<>ctNone) then begin
CurName:=CurRelation.GetCategoryAndName;
ConflictName:=ConflictRelation.GetCategoryAndName;
if conflictType=ctConflictKeyA then
ConflictName:=ConflictName
+' ('+KeyAndShiftStateToEditorKeyString(ConflictRelation.ShortcutA)
else
ConflictName:=ConflictName
+' ('+KeyAndShiftStateToEditorKeyString(ConflictRelation.ShortcutB);
if MessageDlg(lisPEConflictFound,
Format(lisTheKeyIsAlreadyAssignedToRemoveTheOldAssignmentAnd, [
KeyAndShiftStateToEditorKeyString(Key), #13, ConflictName, #13, #13,
#13, CurName]), mtConfirmation, [mbYes, mbNo], 0) <> mrYes then
begin
Result:=false;
exit;
end;
if (conflictType=ctConflictKeyA) then
ConflictRelation.ShortcutA:=ConflictRelation.ShortcutB;
ConflictRelation.ClearShortcutB;
end;
end;
Result:=true;
end;
procedure TShortCutDialog.UpdateCaptions;
begin
if ShowSequence then begin
PrimaryGroupBox.Caption:=lisKeyOr2KeySequence;
SecondaryGroupBox.Caption:=lisAlternativeKeyOr2KeySequence;
end else begin
PrimaryGroupBox.Caption:=lisEdtExtToolKey;
SecondaryGroupBox.Caption:=lisAlternativeKey;
end;
end;
procedure TShortCutDialog.ClearKeys;
begin
PrimaryShortCut:=CleanIDEShortCut;
SecondaryShortCut:=CleanIDEShortCut;
end;
procedure TShortCutDialog.SetRelation(
AKeyCommandRelationList: TKeyCommandRelationList; Index: integer);
var
CurRelation: TKeyCommandRelation;
begin
KeyCommandRelationList:=AKeyCommandRelationList;
RelationIndex:=Index;
CurRelation:=AKeyCommandRelationList.Relations[RelationIndex];
PrimaryShortCut:=CurRelation.ShortcutA;
SecondaryShortCut:=CurRelation.ShortcutB;
Caption:=srkmCommand+' "'+CurRelation.LocalizedName+'"';
end;
initialization
{$I keymapshortcutdlg.lrs}
end.

View File

@ -1691,11 +1691,17 @@ resourcestring
// //
srkmEditKeys ='Edit Keys'; srkmEditKeys ='Edit Keys';
srkmCommand = 'Command:'; srkmCommand = 'Command:';
lisKeyOr2KeySequence = 'Key (or 2 key sequence)';
lisTheKeyIsAlreadyAssignedToRemoveTheOldAssignmentAnd = 'The key %s%sis '
+'already assigned to %s.%s%sRemove the old assignment and assign the key '
+'to the new function%s%s?';
lisAlternativeKeyOr2KeySequence = 'Alternative key (or 2 key sequence)';
srkmConflic = 'Conflict '; srkmConflic = 'Conflict ';
srkmConflicW = ' conflicts with '; srkmConflicW = ' conflicts with ';
srkmCommand1 = ' command1 "'; srkmCommand1 = ' command1 "';
srkmCommand2 = ' command2 "'; srkmCommand2 = ' command2 "';
srkmEditForCmd='Edit keys of command'; srkmEditForCmd='Edit keys of command';
lisChooseAKey = 'Choose a key ...';
srkmKey = 'Key (or 2 keys combination)'; srkmKey = 'Key (or 2 keys combination)';
srkmGrabKey = 'Grab key'; srkmGrabKey = 'Grab key';
srkmGrabSecondKey = 'Grab second key'; srkmGrabSecondKey = 'Grab second key';
@ -2713,6 +2719,7 @@ resourcestring
+'Free Pascal Compiler messages'; +'Free Pascal Compiler messages';
lisEdtExtToolScanOutputForMakeMessages = 'Scan output for make messages'; lisEdtExtToolScanOutputForMakeMessages = 'Scan output for make messages';
lisEdtExtToolKey = 'Key'; lisEdtExtToolKey = 'Key';
lisAlternativeKey = 'Alternative key';
lisEdtExtToolCtrl = 'Ctrl'; lisEdtExtToolCtrl = 'Ctrl';
lisEdtExtToolAlt = 'Alt'; lisEdtExtToolAlt = 'Alt';
lisEdtExtToolShift = 'Shift'; lisEdtExtToolShift = 'Shift';