mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-24 07:19:34 +01:00
IDE: unify the 2 filters in KeyMapping window. Prevent a potential crash.
git-svn-id: trunk@36601 -
This commit is contained in:
parent
2c6aed50c6
commit
b0db3474ba
@ -16,12 +16,12 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame
|
|||||||
AnchorSideRight.Control = Owner
|
AnchorSideRight.Control = Owner
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 418
|
Height = 417
|
||||||
Top = 32
|
Top = 33
|
||||||
Width = 461
|
Width = 461
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
BorderSpacing.Top = 3
|
BorderSpacing.Top = 3
|
||||||
DefaultItemHeight = 18
|
DefaultItemHeight = 16
|
||||||
PopupMenu = PopupMenu1
|
PopupMenu = PopupMenu1
|
||||||
ReadOnly = True
|
ReadOnly = True
|
||||||
RightClickSelect = True
|
RightClickSelect = True
|
||||||
@ -38,24 +38,26 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame
|
|||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = FindKeyButton
|
AnchorSideRight.Control = FindKeyButton
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 23
|
Height = 24
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 248
|
Width = 266
|
||||||
|
OnFilterItem = FilterEditFilterItem
|
||||||
ButtonWidth = 23
|
ButtonWidth = 23
|
||||||
NumGlyphs = 0
|
NumGlyphs = 0
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
BorderSpacing.Top = 6
|
BorderSpacing.Top = 6
|
||||||
MaxLength = 0
|
MaxLength = 0
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
|
OnKeyPress = FilterEditKeyPress
|
||||||
FilteredTreeview = TreeView
|
FilteredTreeview = TreeView
|
||||||
ExpandAllInitially = True
|
ExpandAllInitially = True
|
||||||
end
|
end
|
||||||
object ClearButton: TBitBtn
|
object ClearButton: TBitBtn
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 372
|
Left = 386
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 455
|
Top = 455
|
||||||
Width = 89
|
Width = 75
|
||||||
Anchors = [akRight, akBottom]
|
Anchors = [akRight, akBottom]
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Bottom = 6
|
BorderSpacing.Bottom = 6
|
||||||
@ -69,14 +71,14 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame
|
|||||||
AnchorSideTop.Control = FilterEdit
|
AnchorSideTop.Control = FilterEdit
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
AnchorSideRight.Control = ResetKeyFilterBtn
|
AnchorSideRight.Control = ResetKeyFilterBtn
|
||||||
Left = 320
|
Left = 336
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 5
|
Top = 6
|
||||||
Width = 104
|
Width = 88
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Left = 70
|
BorderSpacing.Left = 70
|
||||||
BorderSpacing.Around = 2
|
BorderSpacing.Right = 2
|
||||||
Caption = 'FindKeyButton'
|
Caption = 'FindKeyButton'
|
||||||
OnClick = FindKeyButtonClick
|
OnClick = FindKeyButtonClick
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
@ -86,10 +88,10 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame
|
|||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
AnchorSideBottom.Control = Owner
|
AnchorSideBottom.Control = Owner
|
||||||
AnchorSideBottom.Side = asrBottom
|
AnchorSideBottom.Side = asrBottom
|
||||||
Left = 302
|
Left = 323
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 485
|
Top = 485
|
||||||
Width = 159
|
Width = 138
|
||||||
Anchors = [akRight, akBottom]
|
Anchors = [akRight, akBottom]
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
Caption = 'ConsistencyCheckButton'
|
Caption = 'ConsistencyCheckButton'
|
||||||
@ -103,7 +105,7 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame
|
|||||||
Left = 0
|
Left = 0
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 485
|
Top = 485
|
||||||
Width = 144
|
Width = 123
|
||||||
Anchors = [akLeft, akBottom]
|
Anchors = [akLeft, akBottom]
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
Caption = 'ChooseSchemeButton'
|
Caption = 'ChooseSchemeButton'
|
||||||
@ -115,10 +117,10 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame
|
|||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = ChooseSchemeButton
|
AnchorSideTop.Control = ChooseSchemeButton
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 150
|
Left = 129
|
||||||
Height = 16
|
Height = 15
|
||||||
Top = 489
|
Top = 490
|
||||||
Width = 71
|
Width = 67
|
||||||
BorderSpacing.Around = 6
|
BorderSpacing.Around = 6
|
||||||
Caption = 'SchemeLabel'
|
Caption = 'SchemeLabel'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
@ -127,10 +129,10 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame
|
|||||||
AnchorSideTop.Control = ClearButton
|
AnchorSideTop.Control = ClearButton
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
AnchorSideRight.Control = ClearButton
|
AnchorSideRight.Control = ClearButton
|
||||||
Left = 284
|
Left = 311
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 455
|
Top = 455
|
||||||
Width = 82
|
Width = 69
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Right = 6
|
BorderSpacing.Right = 6
|
||||||
@ -143,10 +145,10 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame
|
|||||||
AnchorSideTop.Control = EditButton
|
AnchorSideTop.Control = EditButton
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
AnchorSideRight.Control = EditButton
|
AnchorSideRight.Control = EditButton
|
||||||
Left = 192
|
Left = 227
|
||||||
Height = 16
|
Height = 15
|
||||||
Top = 459
|
Top = 460
|
||||||
Width = 86
|
Width = 78
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
BorderSpacing.Right = 6
|
BorderSpacing.Right = 6
|
||||||
Caption = 'CommandLabel'
|
Caption = 'CommandLabel'
|
||||||
@ -159,7 +161,7 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame
|
|||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 426
|
Left = 426
|
||||||
Height = 22
|
Height = 22
|
||||||
Top = 6
|
Top = 7
|
||||||
Width = 29
|
Width = 29
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
BorderSpacing.Right = 6
|
BorderSpacing.Right = 6
|
||||||
@ -168,8 +170,8 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame
|
|||||||
end
|
end
|
||||||
object PopupMenu1: TPopupMenu
|
object PopupMenu1: TPopupMenu
|
||||||
OnPopup = PopupMenu1Popup
|
OnPopup = PopupMenu1Popup
|
||||||
left = 356
|
left = 352
|
||||||
top = 16
|
top = 48
|
||||||
object EditMenuItem: TMenuItem
|
object EditMenuItem: TMenuItem
|
||||||
Caption = 'Edit Key Mapping'
|
Caption = 'Edit Key Mapping'
|
||||||
OnClick = EditMenuItemClick
|
OnClick = EditMenuItemClick
|
||||||
|
|||||||
@ -55,6 +55,8 @@ type
|
|||||||
procedure ChooseSchemeButtonClick(Sender: TObject);
|
procedure ChooseSchemeButtonClick(Sender: TObject);
|
||||||
procedure ClearButtonClick(Sender: TObject);
|
procedure ClearButtonClick(Sender: TObject);
|
||||||
procedure ConsistencyCheckButtonClick(Sender: TObject);
|
procedure ConsistencyCheckButtonClick(Sender: TObject);
|
||||||
|
function FilterEditFilterItem(Item: TObject; out Done: Boolean): Boolean;
|
||||||
|
procedure FilterEditKeyPress(Sender: TObject; var Key: char);
|
||||||
procedure FindKeyButtonClick(Sender: TObject);
|
procedure FindKeyButtonClick(Sender: TObject);
|
||||||
procedure ResetKeyFilterBtnClick(Sender: TObject);
|
procedure ResetKeyFilterBtnClick(Sender: TObject);
|
||||||
procedure TreeViewDblClick(Sender: TObject);
|
procedure TreeViewDblClick(Sender: TObject);
|
||||||
@ -178,13 +180,13 @@ var
|
|||||||
NewScheme: String;
|
NewScheme: String;
|
||||||
begin
|
begin
|
||||||
NewScheme := EditorOpts.KeyMappingScheme;
|
NewScheme := EditorOpts.KeyMappingScheme;
|
||||||
if ShowChooseKeySchemeDialog(NewScheme) <> mrOk then
|
if ShowChooseKeySchemeDialog(NewScheme) = mrOk then begin
|
||||||
Exit;
|
EditorOpts.KeyMappingScheme := NewScheme;
|
||||||
EditorOpts.KeyMappingScheme := NewScheme;
|
EditingKeyMap.LoadScheme(NewScheme);
|
||||||
EditingKeyMap.LoadScheme(NewScheme);
|
FillKeyMappingTreeView;
|
||||||
FillKeyMappingTreeView;
|
fModified:=False;
|
||||||
fModified:=False;
|
UpdateSchemeLabel;
|
||||||
UpdateSchemeLabel;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TEditorKeymappingOptionsFrame.EditButtonClick(Sender: TObject);
|
procedure TEditorKeymappingOptionsFrame.EditButtonClick(Sender: TObject);
|
||||||
@ -228,23 +230,47 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TEditorKeymappingOptionsFrame.FilterEditFilterItem(Item: TObject; out Done: Boolean): Boolean;
|
||||||
|
var
|
||||||
|
KeyRel: TKeyCommandRelation;
|
||||||
|
begin
|
||||||
|
Done:=True;
|
||||||
|
Result:=False;
|
||||||
|
if Item is TKeyCommandRelation then begin
|
||||||
|
KeyRel:=TKeyCommandRelation(Item); // Tree item is actual key command.
|
||||||
|
Done:=False;
|
||||||
|
Result:=KeyMapKeyFilter.Key1<>VK_UNKNOWN;
|
||||||
|
if Result then begin // Key filter is defined
|
||||||
|
Done:=True;
|
||||||
|
Result:=(CompareIDEShortCutKey1s(@KeyMapKeyFilter,@KeyRel.ShortcutA)=0)
|
||||||
|
or (CompareIDEShortCutKey1s(@KeyMapKeyFilter,@KeyRel.ShortcutB)=0);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TEditorKeymappingOptionsFrame.FilterEditKeyPress(Sender: TObject; var Key: char);
|
||||||
|
begin
|
||||||
|
ResetKeyFilterBtnClick(Nil);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TEditorKeymappingOptionsFrame.FindKeyButtonClick(Sender: TObject);
|
procedure TEditorKeymappingOptionsFrame.FindKeyButtonClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
KeyFilter: TIDEShortCut;
|
KeyFilter: TIDEShortCut;
|
||||||
begin
|
begin
|
||||||
if ShowKeyMappingGrabForm(KeyFilter) <> mrOK then
|
if ShowKeyMappingGrabForm(KeyFilter) = mrOK then begin
|
||||||
Exit;
|
KeyMapKeyFilter := KeyFilter;
|
||||||
KeyMapKeyFilter := KeyFilter;
|
UpdateKeyFilterButton;
|
||||||
UpdateKeyFilterButton;
|
FilterEdit.Filter:=''; // Allow only one of the filters to be active.
|
||||||
FillKeyMappingTreeView;
|
FilterEdit.InvalidateFilter;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TEditorKeymappingOptionsFrame.ResetKeyFilterBtnClick(Sender: TObject);
|
procedure TEditorKeymappingOptionsFrame.ResetKeyFilterBtnClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
KeyMapKeyFilter.Key1 := VK_UNKNOWN;
|
KeyMapKeyFilter.Key1 := VK_UNKNOWN;
|
||||||
KeyMapKeyFilter.Key2 := VK_UNKNOWN;
|
KeyMapKeyFilter.Key2 := VK_UNKNOWN;
|
||||||
UpdateKeyFilterButton;
|
UpdateKeyFilterButton; // Allow only one of the filters to be active.
|
||||||
FillKeyMappingTreeView;
|
FilterEdit.InvalidateFilter;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TEditorKeymappingOptionsFrame.TreeViewDblClick(Sender: TObject);
|
procedure TEditorKeymappingOptionsFrame.TreeViewDblClick(Sender: TObject);
|
||||||
@ -331,8 +357,8 @@ begin
|
|||||||
ResetKeyFilterBtn.LoadGlyphFromLazarusResource(ResBtnListFilter);
|
ResetKeyFilterBtn.LoadGlyphFromLazarusResource(ResBtnListFilter);
|
||||||
ResetKeyFilterBtn.Enabled := not IDEShortCutEmpty(KeyMapKeyFilter);
|
ResetKeyFilterBtn.Enabled := not IDEShortCutEmpty(KeyMapKeyFilter);
|
||||||
|
|
||||||
FillKeyMappingTreeView;
|
// FillKeyMappingTreeView; ... Done in ReadSettings.
|
||||||
UpdateSchemeLabel;
|
// UpdateSchemeLabel;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TEditorKeymappingOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
|
procedure TEditorKeymappingOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
|
||||||
@ -342,7 +368,7 @@ begin
|
|||||||
with AOptions as TEditorOptions do
|
with AOptions as TEditorOptions do
|
||||||
EditingKeyMap.Assign(KeyMap);
|
EditingKeyMap.Assign(KeyMap);
|
||||||
FillKeyMappingTreeView;
|
FillKeyMappingTreeView;
|
||||||
|
UpdateSchemeLabel;
|
||||||
with GeneralPage do
|
with GeneralPage do
|
||||||
for i := Low(PreviewEdits) to High(PreviewEdits) do
|
for i := Low(PreviewEdits) to High(PreviewEdits) do
|
||||||
if PreviewEdits[i] <> nil then
|
if PreviewEdits[i] <> nil then
|
||||||
@ -392,11 +418,6 @@ begin
|
|||||||
begin
|
begin
|
||||||
CurKeyRelation := TKeyCommandRelation(CurCategory[j]);
|
CurKeyRelation := TKeyCommandRelation(CurCategory[j]);
|
||||||
ItemCaption:=KeyMappingRelationToString(CurKeyRelation);
|
ItemCaption:=KeyMappingRelationToString(CurKeyRelation);
|
||||||
if (KeyMapKeyFilter.Key1<>VK_UNKNOWN)
|
|
||||||
and (CompareIDEShortCutKey1s(@KeyMapKeyFilter,@CurKeyRelation.ShortcutA)<>0)
|
|
||||||
and (CompareIDEShortCutKey1s(@KeyMapKeyFilter,@CurKeyRelation.ShortcutB)<>0)
|
|
||||||
then
|
|
||||||
continue;
|
|
||||||
if NewCategoryNode.Count > ChildNodeIndex then
|
if NewCategoryNode.Count > ChildNodeIndex then
|
||||||
begin
|
begin
|
||||||
NewKeyNode := NewCategoryNode.Items[ChildNodeIndex];
|
NewKeyNode := NewCategoryNode.Items[ChildNodeIndex];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user