IDE: Add a selection tool button to ComponentList window. Clear selection when emptying filter. Issue #34256, patch from accorp.

git-svn-id: trunk@58955 -
This commit is contained in:
juha 2018-09-11 23:12:49 +00:00
parent 8108e85270
commit 4f59b471d1
2 changed files with 50 additions and 6 deletions

View File

@ -140,10 +140,27 @@ object ComponentListForm: TComponentListForm
ClientHeight = 27
ClientWidth = 300
TabOrder = 0
object LabelSearch: TLabel
object SelectionToolButton: TSpeedButton
AnchorSideLeft.Control = FilterPanel
AnchorSideTop.Control = FilterPanel
Left = 6
AnchorSideBottom.Control = FilterPanel
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 27
Top = 0
Width = 32
AllowAllUp = True
Anchors = [akTop, akLeft, akBottom]
Down = True
Flat = True
GroupIndex = 1
OnClick = SelectionToolButtonClick
end
object LabelSearch: TLabel
AnchorSideLeft.Control = SelectionToolButton
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = FilterPanel
Left = 38
Height = 15
Top = 6
Width = 63

View File

@ -32,10 +32,16 @@ unit ComponentList;
interface
uses
Classes, SysUtils, LCLType, Forms, Controls, Graphics, StdCtrls, ExtCtrls,
ComCtrls, Menus, Dialogs, LazarusIDEStrConsts, ComponentReg, PackageDefs,
IDEImagesIntf, TreeFilterEdit, FormEditingIntf, PropEdits, IDEOptionDefs,
EnvironmentOpts, Designer, ImgList;
Classes, SysUtils,
// LCL
LCLType, Forms, Controls, Graphics, StdCtrls, ExtCtrls, ComCtrls, Menus, Buttons,
Dialogs, ImgList,
// LazControls
TreeFilterEdit,
// IdeIntf
FormEditingIntf, PropEdits, ComponentReg,
// IDE
LazarusIDEStrConsts, PackageDefs, IDEOptionDefs, EnvironmentOpts, Designer;
type
@ -64,6 +70,7 @@ type
TabSheetList: TTabSheet;
tmDeselect: TTimer;
TreeFilterEd: TTreeFilterEdit;
SelectionToolButton: TSpeedButton;
procedure chbKeepOpenChange(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormShow(Sender: TObject);
@ -81,6 +88,7 @@ type
procedure PageControlChange(Sender: TObject);
procedure TreeKeyPress(Sender: TObject; var Key: char);
procedure FormKeyDown(Sender: TObject; var Key: Word; {%H-}Shift: TShiftState);
procedure SelectionToolButtonClick(Sender: TObject);
private
PrevPageIndex: Integer;
PrevChangeStamp: Integer;
@ -125,6 +133,14 @@ begin
Name:=NonModalIDEWindowNames[nmiwComponentList];
FActiveTree := ListTree;
with SelectionToolButton do begin
LoadGlyphFromResourceName(hInstance, 'tmouse');
ShowHint := EnvironmentOptions.ShowHintsForComponentPalette;
Width := ComponentPaletteBtnWidth;
BorderSpacing.Around := (FilterPanel.Height - ComponentPaletteImageHeight) div 2;
end;
//Translations
LabelSearch.Caption := lisMenuFind;
Caption := lisCmpLstComponents;
@ -133,6 +149,7 @@ begin
TabSheetInheritance.Caption := lisCmpLstInheritance;
OKButton.Caption := lisUse;
chbKeepOpen.Caption := lisKeepOpen;
SelectionToolButton.Hint := lisSelectionTool;
ListTree.Images := TPkgComponent.Images;
PalletteTree.Images := TPkgComponent.Images;
@ -251,6 +268,8 @@ end;
procedure TComponentListForm.SelectionWasChanged;
begin
SelectionToolButton.Down := (IDEComponentPalette.Selected = nil);
// ToDo: Select the component in active treeview.
if FIgnoreSelection then
Exit;
@ -433,6 +452,8 @@ end;
procedure TComponentListForm.TreeFilterEdAfterFilter(Sender: TObject);
begin
if TreeFilterEd.Filter = '' then
IDEComponentPalette.SetSelectedComp(nil, False);
UpdateButtonState;
end;
@ -608,5 +629,11 @@ begin
end;
end;
procedure TComponentListForm.SelectionToolButtonClick(Sender: TObject);
begin
SelectionToolButton.Down := True;
IDEComponentPalette.SetSelectedComp(nil, False);
end;
end.