IDE: In ComponentList show Designer when selecting component or clicking on selection button. Merge request !399 by n7800.

This commit is contained in:
Juha 2024-12-07 07:49:09 +02:00
parent e5f9504c5f
commit ca8d8b9b84
3 changed files with 24 additions and 2 deletions

View File

@ -54,6 +54,7 @@ object ComponentListForm: TComponentListForm
TabOrder = 0
OnDblClick = ComponentsDblClick
OnKeyPress = TreeKeyPress
OnMouseDown = TreeMouseDown
OnSelectionChanged = ListTreeSelectionChanged
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRowSelect, tvoToolTips]
end
@ -90,6 +91,7 @@ object ComponentListForm: TComponentListForm
TabOrder = 0
OnDblClick = ComponentsDblClick
OnKeyPress = TreeKeyPress
OnMouseDown = TreeMouseDown
OnSelectionChanged = ListTreeSelectionChanged
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoRowSelect, tvoShowButtons, tvoShowRoot, tvoToolTips]
end
@ -126,6 +128,7 @@ object ComponentListForm: TComponentListForm
TabOrder = 0
OnDblClick = ComponentsDblClick
OnKeyPress = TreeKeyPress
OnMouseDown = TreeMouseDown
OnSelectionChanged = ListTreeSelectionChanged
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoRowSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips]
end

View File

@ -89,6 +89,8 @@ type
SelectionToolButton: TSpeedButton;
procedure chbKeepOpenChange(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TreeMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure ListTreeSelectionChanged(Sender: TObject);
procedure miCollapseAllClick(Sender: TObject);
procedure miCollapseClick(Sender: TObject);
@ -111,6 +113,7 @@ type
private
FOnOpenPackage: TNotifyEvent;
FOnOpenUnit: TNotifyEvent;
FOnClassSelected: TNotifyEvent;
PrevChangeStamp: Integer;
FInitialized: Boolean;
FIgnoreSelection: Boolean;
@ -138,6 +141,7 @@ type
function GetSelectedPkgComp: TPkgComponent;
property OnOpenPackage: TNotifyEvent read FOnOpenPackage write FOnOpenPackage;
property OnOpenUnit: TNotifyEvent read FOnOpenUnit write FOnOpenUnit;
property OnClassSelected: TNotifyEvent read FOnClassSelected write FOnClassSelected;
end;
var
@ -611,6 +615,16 @@ begin
end
end;
procedure TComponentListForm.TreeMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
// ignore right click to bring up context menu
if (Button <> mbLeft) or IsDocked or chbKeepOpen.Checked then Exit;
// show form editor
if assigned(OnClassSelected) then
OnClassSelected(self);
end;
procedure TComponentListForm.TreeKeyPress(Sender: TObject; var Key: char);
// This is used for all 3 treeviews
begin
@ -748,8 +762,8 @@ begin
if (OldFocusedControl<>nil) and OldFocusedControl.CanSetFocus then
OldFocusedControl.SetFocus; // AddComponent in docked mode steals focus to designer, get it back
if not IsDocked and not chbKeepOpen.Checked then
Close;
if IsDocked or chbKeepOpen.Checked then Exit;
Close;
end;
procedure TComponentListForm.miCollapseAllClick(Sender: TObject);
@ -861,6 +875,10 @@ procedure TComponentListForm.SelectionToolButtonClick(Sender: TObject);
begin
SelectionToolButton.Down := True;
IDEComponentPalette.SetSelectedComp(nil, False);
if IsDocked or chbKeepOpen.Checked then Exit;
// show form editor
if assigned(OnClassSelected) then
OnClassSelected(self);
end;
end.

View File

@ -6166,6 +6166,7 @@ begin
State=iwgfDisabled,OwningComponent);
ComponentListForm.OnOpenPackage:=@PkgBoss.IDEComponentPaletteOpenPackage;
ComponentListForm.OnOpenUnit:=@PkgBoss.IDEComponentPaletteOpenUnit;
ComponentListForm.OnClassSelected:=@ComponentPaletteClassSelected;
end else if State=iwgfDisabled then
ComponentListForm.DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TMainIDE.DoShowComponentList'){$ENDIF};
if State>=iwgfShow then