mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 12:39:29 +02:00
designer, component palette: turn "multy" mode on when shift is pressed during component selection (issue #0008052)
git-svn-id: trunk@21537 -
This commit is contained in:
parent
e9eb6109a6
commit
c680ad8794
@ -102,7 +102,7 @@ type
|
||||
FOnSaveAsXML: TNotifyEvent;
|
||||
FOnSetDesigning: TOnSetDesigning;
|
||||
FOnShowOptions: TNotifyEvent;
|
||||
FOnUnselectComponentClass: TNotifyEvent;
|
||||
FOnComponentAdded: TNotifyEvent;
|
||||
FOnViewLFM: TNotifyEvent;
|
||||
FShiftState: TShiftState;
|
||||
FTheFormEditor: TCustomFormEditor;
|
||||
@ -303,9 +303,9 @@ type
|
||||
read FOnRenameComponent write FOnRenameComponent;
|
||||
property OnSetDesigning: TOnSetDesigning
|
||||
read FOnSetDesigning write FOnSetDesigning;
|
||||
property OnUnselectComponentClass: TNotifyEvent
|
||||
read FOnUnselectComponentClass
|
||||
write FOnUnselectComponentClass;
|
||||
property OnComponentAdded: TNotifyEvent
|
||||
read FOnComponentAdded
|
||||
write FOnComponentAdded;
|
||||
property OnShowOptions: TNotifyEvent
|
||||
read FOnShowOptions write FOnShowOptions;
|
||||
property OnViewLFM: TNotifyEvent read FOnViewLFM write FOnViewLFM;
|
||||
@ -1582,10 +1582,8 @@ var
|
||||
// creation completed
|
||||
// -> select new component
|
||||
SelectOnlyThisComponent(NewComponent);
|
||||
if not (ssShift in Shift) then
|
||||
if Assigned(FOnUnselectComponentClass) then
|
||||
// this resets the component palette to the selection tool
|
||||
FOnUnselectComponentClass(Self);
|
||||
if Assigned(FOnComponentAdded) then // this resets the component palette to the selection tool
|
||||
FOnComponentAdded(Self);
|
||||
|
||||
{$IFDEF VerboseDesigner}
|
||||
DebugLn('NEW COMPONENT ADDED: Form.ComponentCount=',DbgS(Form.ComponentCount),
|
||||
|
@ -48,6 +48,11 @@ uses
|
||||
FindPaletteComp;
|
||||
|
||||
type
|
||||
TComponentSelectionMode = (
|
||||
csmSingle, // reset selection on component add
|
||||
csmMulty // don't reset selection on component add
|
||||
);
|
||||
|
||||
{ TComponentPalette }
|
||||
|
||||
TComponentPalette = class(TBaseComponentPalette)
|
||||
@ -68,6 +73,7 @@ type
|
||||
FOnOpenPackage: TNotifyEvent;
|
||||
FOnOpenUnit: TNotifyEvent;
|
||||
FSelected: TRegisteredComponent;
|
||||
FSelectionMode: TComponentSelectionMode;
|
||||
fUnregisteredIcon: TCustomBitmap;
|
||||
fSelectButtonIcon: TCustomBitmap;
|
||||
fUpdatingNotebook: boolean;
|
||||
@ -88,6 +94,7 @@ type
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure DoAfterComponentAdded;
|
||||
function GetUnregisteredIcon: TCustomBitmap;
|
||||
function GetSelectButtonIcon: TCustomBitmap;
|
||||
procedure ClearButtons; override;
|
||||
@ -103,6 +110,7 @@ type
|
||||
public
|
||||
property NoteBook: TNotebook read FNoteBook write SetNoteBook;
|
||||
property Selected: TRegisteredComponent read FSelected write SetSelected;
|
||||
property SelectionMode: TComponentSelectionMode read FSelectionMode write FSelectionMode;
|
||||
property OnOpenPackage: TNotifyEvent read FOnOpenPackage write FOnOpenPackage;
|
||||
property OnOpenUnit: TNotifyEvent read FOnOpenUnit write FOnOpenUnit;
|
||||
end;
|
||||
@ -228,6 +236,10 @@ end;
|
||||
|
||||
procedure TComponentPalette.ComponentBtnClick(Sender: TObject);
|
||||
begin
|
||||
if ssShift in GetKeyShiftState then
|
||||
SelectionMode := csmMulty
|
||||
else
|
||||
SelectionMode := csmSingle;
|
||||
SelectButton(TComponent(Sender));
|
||||
end;
|
||||
|
||||
@ -369,6 +381,7 @@ end;
|
||||
constructor TComponentPalette.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
FSelectionMode := csmSingle;
|
||||
fComponents:=TAVLTree.Create(@CompareRegisteredComponents);
|
||||
OnComponentIsInvisible:=@CheckComponentDesignerVisible;
|
||||
end;
|
||||
@ -385,6 +398,12 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TComponentPalette.DoAfterComponentAdded;
|
||||
begin
|
||||
if not (ssShift in GetKeyShiftState) and (SelectionMode = csmSingle) then
|
||||
Selected := nil;
|
||||
end;
|
||||
|
||||
function TComponentPalette.GetUnregisteredIcon: TCustomBitMap;
|
||||
begin
|
||||
if fUnregisteredIcon = nil then
|
||||
@ -422,9 +441,9 @@ function TComponentPalette.SelectButton(Button: TComponent): boolean;
|
||||
var
|
||||
NewComponent: TRegisteredComponent;
|
||||
begin
|
||||
NewComponent:=FindButton(Button);
|
||||
Selected:=NewComponent;
|
||||
Result:=(Selected=NewComponent);
|
||||
NewComponent := FindButton(Button);
|
||||
Selected := NewComponent;
|
||||
Result := (Selected = NewComponent);
|
||||
end;
|
||||
|
||||
procedure TComponentPalette.ReAlignButtons(Page: TPage);
|
||||
|
@ -437,7 +437,7 @@ type
|
||||
// designer events
|
||||
procedure OnDesignerGetSelectedComponentClass(Sender: TObject;
|
||||
var RegisteredComponent: TRegisteredComponent);
|
||||
procedure OnDesignerUnselectComponentClass(Sender: TObject);
|
||||
procedure OnDesignerComponentAdded(Sender: TObject);
|
||||
procedure OnDesignerSetDesigning(Sender: TObject; Component: TComponent;
|
||||
Value: boolean);
|
||||
procedure OnDesignerShowOptions(Sender: TObject);
|
||||
@ -3152,7 +3152,7 @@ begin
|
||||
OnRenameComponent:=@OnDesignerRenameComponent;
|
||||
OnSetDesigning:=@OnDesignerSetDesigning;
|
||||
OnShowOptions:=@OnDesignerShowOptions;
|
||||
OnUnselectComponentClass:=@OnDesignerUnselectComponentClass;
|
||||
OnComponentAdded:=@OnDesignerComponentAdded;
|
||||
OnViewLFM:=@OnDesignerViewLFM;
|
||||
OnSaveAsXML:=@OnDesignerSaveAsXML;
|
||||
ShowEditorHints:=EnvironmentOptions.ShowEditorHints;
|
||||
@ -11812,9 +11812,9 @@ begin
|
||||
RegisteredComponent:=TComponentPalette(IDEComponentPalette).Selected;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.OnDesignerUnselectComponentClass(Sender: TObject);
|
||||
procedure TMainIDE.OnDesignerComponentAdded(Sender: TObject);
|
||||
begin
|
||||
TComponentPalette(IDEComponentPalette).Selected:=nil;
|
||||
TComponentPalette(IDEComponentPalette).DoAfterComponentAdded;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.OnDesignerSetDesigning(Sender: TObject;
|
||||
|
Loading…
Reference in New Issue
Block a user