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