mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 02:19:57 +02:00
IdeIntf: Update Object Inspector after changing order of items in ActionList Editor. Issue #36872.
git-svn-id: trunk@62926 -
This commit is contained in:
parent
9f4231ee15
commit
25a0114031
@ -147,7 +147,8 @@ type
|
||||
override;
|
||||
private
|
||||
FActionList: TActionList;
|
||||
FDesigner: TComponentEditorDesigner;
|
||||
FCompDesigner: TComponentEditorDesigner;
|
||||
FCompEditor: TActionListComponentEditor;
|
||||
procedure AddCategoryActions(aCategory: String);
|
||||
function CategoryIndexOf(Category: String): Integer;
|
||||
function IsValidCategory(Category: String): Boolean;
|
||||
@ -160,7 +161,6 @@ type
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure SetActionList(AActionList: TActionList);
|
||||
property Designer:TComponentEditorDesigner read FDesigner write FDesigner;
|
||||
end;
|
||||
|
||||
{ TActionListComponentEditor }
|
||||
@ -168,7 +168,7 @@ type
|
||||
TActionListComponentEditor = class(TComponentEditor)
|
||||
private
|
||||
FActionList: TActionList;
|
||||
FDesigner: TComponentEditorDesigner;
|
||||
FCompDesigner: TComponentEditorDesigner;
|
||||
protected
|
||||
public
|
||||
constructor Create(AComponent: TComponent;
|
||||
@ -602,7 +602,7 @@ begin
|
||||
if Category <> cActionListEditorUnknownCategory
|
||||
then NewAction.Category := Category
|
||||
else NewAction.Category := '';
|
||||
NewAction.Name := FDesigner.CreateUniqueComponentName(NewAction.ClassName);
|
||||
NewAction.Name := FCompDesigner.CreateUniqueComponentName(NewAction.ClassName);
|
||||
|
||||
if Assigned(ActionProperty) then begin
|
||||
TCustomAction(NewAction).Caption := ActionProperty.ActionProperty.Caption;
|
||||
@ -611,11 +611,11 @@ begin
|
||||
end;
|
||||
|
||||
NewAction.ActionList := FActionList;
|
||||
FDesigner.PropertyEditorHook.PersistentAdded(NewAction,True);
|
||||
FCompDesigner.PropertyEditorHook.PersistentAdded(NewAction,True);
|
||||
|
||||
FDesigner.Modified;
|
||||
FCompDesigner.Modified;
|
||||
if LastItem then
|
||||
FDesigner.SelectOnlyThisComponent(FActionList.ActionByName(NewAction.Name));
|
||||
FCompDesigner.SelectOnlyThisComponent(FActionList.ActionByName(NewAction.Name));
|
||||
end;
|
||||
|
||||
procedure TActionListEditor.SplitterCanResize(Sender: TObject;
|
||||
@ -681,7 +681,7 @@ begin
|
||||
|
||||
lstActionName.Items.Move(lboxIndex, lboxIndex+direction);
|
||||
lstActionName.ItemIndex := lboxIndex+direction;
|
||||
FDesigner.Modified;
|
||||
FCompDesigner.PropertyEditorHook.Modified(FCompEditor);
|
||||
end;
|
||||
|
||||
procedure TActionListEditor.ActMoveDownUpdate(Sender: TObject);
|
||||
@ -703,7 +703,7 @@ var
|
||||
begin
|
||||
if FActionList=nil then exit;
|
||||
NewAction := TAction.Create(FActionList.Owner);
|
||||
NewAction.Name := FDesigner.CreateUniqueComponentName(NewAction.ClassName);
|
||||
NewAction.Name := FCompDesigner.CreateUniqueComponentName(NewAction.ClassName);
|
||||
|
||||
if lstCategory.ItemIndex > 1 // ignore first two items (virtual categories)
|
||||
then NewAction.Category := lstCategory.Items[lstCategory.ItemIndex]
|
||||
@ -714,9 +714,9 @@ begin
|
||||
// Selection updates correctly when we first clear the selection in Designer
|
||||
// and in Object Inspector, then add a new item. Otherwise there is
|
||||
// a loop of back-and-forth selection updates and the new item does not show.
|
||||
FDesigner.ClearSelection;
|
||||
FDesigner.PropertyEditorHook.PersistentAdded(NewAction,True);
|
||||
FDesigner.Modified;
|
||||
FCompDesigner.ClearSelection;
|
||||
FCompDesigner.PropertyEditorHook.PersistentAdded(NewAction,True);
|
||||
FCompDesigner.Modified;
|
||||
end;
|
||||
|
||||
procedure TActionListEditor.ActNewStdExecute(Sender: TObject);
|
||||
@ -836,7 +836,7 @@ begin
|
||||
if Assigned(OldAction) then
|
||||
begin
|
||||
try
|
||||
FDesigner.PropertyEditorHook.DeletePersistent(TPersistent(OldAction));
|
||||
FCompDesigner.PropertyEditorHook.DeletePersistent(TPersistent(OldAction));
|
||||
OldAction:=nil;
|
||||
except
|
||||
on E: Exception do begin
|
||||
@ -855,7 +855,7 @@ begin
|
||||
then lstActionName.ItemIndex := lstActionName.Items.Count -1
|
||||
else lstActionName.ItemIndex := iNameIndex;
|
||||
|
||||
FDesigner.SelectOnlyThisComponent(
|
||||
FCompDesigner.SelectOnlyThisComponent(
|
||||
FActionList.ActionByName(lstActionName.Items[lstActionName.ItemIndex]));
|
||||
end;
|
||||
|
||||
@ -865,7 +865,7 @@ begin
|
||||
lstCategory.Items.Delete(OldIndex);
|
||||
end;
|
||||
if lstActionName.ItemIndex < 0
|
||||
then FDesigner.SelectOnlyThisComponent(FActionList);
|
||||
then FCompDesigner.SelectOnlyThisComponent(FActionList);
|
||||
end;
|
||||
|
||||
procedure TActionListEditor.lstCategoryClick(Sender: TObject);
|
||||
@ -883,7 +883,7 @@ begin
|
||||
CurAction := GetSelectedAction;
|
||||
if CurAction = nil then Exit;
|
||||
|
||||
FDesigner.SelectOnlyThisComponent(CurAction);
|
||||
FCompDesigner.SelectOnlyThisComponent(CurAction);
|
||||
end;
|
||||
|
||||
procedure TActionListEditor.lstActionNameDblClick(Sender: TObject);
|
||||
@ -1028,7 +1028,7 @@ begin
|
||||
if i > -1 then
|
||||
lstActionName.ItemIndex := i
|
||||
else if lstActionName.ItemIndex = -1 then
|
||||
FDesigner.SelectOnlyThisComponent(FActionList);
|
||||
FCompDesigner.SelectOnlyThisComponent(FActionList);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -1039,11 +1039,12 @@ constructor TActionListComponentEditor.Create(AComponent: TComponent;
|
||||
ADesigner: TComponentEditorDesigner);
|
||||
begin
|
||||
inherited Create(AComponent, ADesigner);
|
||||
FDesigner := ADesigner;
|
||||
FCompDesigner := ADesigner;
|
||||
end;
|
||||
|
||||
destructor TActionListComponentEditor.Destroy;
|
||||
begin
|
||||
DebugLn(['TActionListComponentEditor.Destroy']);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
@ -1055,14 +1056,13 @@ begin
|
||||
AActionList := GetComponent as TActionList;
|
||||
if AActionList = nil
|
||||
then raise Exception.Create('TActionListComponentEditor.Edit AActionList=nil');
|
||||
AEditor:=FindActionEditor(AActionList);
|
||||
AEditor := FindActionEditor(AActionList);
|
||||
if not Assigned(AEditor) then begin
|
||||
AEditor:=TActionListEditor.Create(Application);
|
||||
with AEditor do begin
|
||||
lstActionName.ItemIndex := -1;
|
||||
Designer := Self.FDesigner;
|
||||
SetActionList(AActionList);
|
||||
end;
|
||||
AEditor := TActionListEditor.Create(Application);
|
||||
AEditor.lstActionName.ItemIndex := -1;
|
||||
AEditor.FCompDesigner := Self.FCompDesigner;
|
||||
AEditor.FCompEditor := Self;
|
||||
AEditor.SetActionList(AActionList);
|
||||
end;
|
||||
SetPopupModeParentForPropertyEditor(AEditor);
|
||||
AEditor.ShowOnTop;
|
||||
|
@ -81,7 +81,6 @@ type
|
||||
function InsertFromStream(s: TStream; Parent: TWinControl;
|
||||
Flags: TComponentPasteSelectionFlags
|
||||
): Boolean; virtual; abstract;
|
||||
function InvokeComponentEditor(AComponent: TComponent): boolean; virtual; abstract;
|
||||
function ChangeClass: boolean; virtual; abstract;
|
||||
|
||||
function CanUndo: Boolean; virtual; abstract;
|
||||
|
@ -294,7 +294,6 @@ type
|
||||
function CopySelectionToStream(AllComponentsStream: TStream): boolean; override;
|
||||
function InsertFromStream(s: TStream; Parent: TWinControl;
|
||||
PasteFlags: TComponentPasteSelectionFlags): Boolean; override;
|
||||
function InvokeComponentEditor(AComponent: TComponent): boolean; override;
|
||||
function ChangeClass: boolean; override;
|
||||
|
||||
procedure DoProcessCommand(Sender: TObject; var Command: word;
|
||||
@ -1709,41 +1708,6 @@ begin
|
||||
Result:=DoDeleteSelectedPersistents;
|
||||
end;
|
||||
|
||||
function TDesigner.InvokeComponentEditor(AComponent: TComponent): boolean;
|
||||
var
|
||||
CompEditor: TBaseComponentEditor;
|
||||
begin
|
||||
Result:=false;
|
||||
DebugLn('TDesigner.InvokeComponentEditor A ',AComponent.Name,':',AComponent.ClassName);
|
||||
CompEditor:=TheFormEditor.GetComponentEditor(AComponent);
|
||||
if CompEditor=nil then begin
|
||||
DebugLn('TDesigner.InvokeComponentEditor',
|
||||
' WARNING: no component editor found for ',
|
||||
AComponent.Name,':',AComponent.ClassName);
|
||||
exit;
|
||||
end;
|
||||
DebugLn('TDesigner.InvokeComponentEditor B ',CompEditor.ClassName);
|
||||
try
|
||||
CompEditor.Edit;
|
||||
Result:=true;
|
||||
except
|
||||
on E: Exception do begin
|
||||
DebugLn('TDesigner.InvokeComponentEditor ERROR: ',E.Message);
|
||||
IDEMessageDialog(Format(lisErrorIn, [CompEditor.ClassName]),
|
||||
Format(lisTheComponentEditorOfClassHasCreatedTheError,
|
||||
[CompEditor.ClassName, LineEnding, E.Message]),
|
||||
mtError,[mbOk]);
|
||||
end;
|
||||
end;
|
||||
try
|
||||
CompEditor.Free;
|
||||
except
|
||||
on E: Exception do begin
|
||||
DebugLn('TDesigner.InvokeComponentEditor ERROR freeing component editor: ',E.Message);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TDesigner.ChangeClass: boolean;
|
||||
begin
|
||||
if (Selection.Count=1) and (not Selection.LookupRootSelected) then
|
||||
@ -2455,22 +2419,6 @@ var
|
||||
Form.Invalidate;
|
||||
end;
|
||||
|
||||
procedure PointSelect;
|
||||
begin
|
||||
if not (ssShift in Shift) then
|
||||
begin
|
||||
// select only the mouse down component
|
||||
Selection.AssignPersistent(MouseDownComponent);
|
||||
if (ssDouble in MouseDownShift) and (Selection.SelectionForm = Form) then
|
||||
begin
|
||||
// Double Click -> invoke 'Edit' of the component editor
|
||||
FShiftState := Shift;
|
||||
InvokeComponentEditor(MouseDownComponent);
|
||||
FShiftState := [];
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure DisableRubberBand;
|
||||
begin
|
||||
if Selection.RubberbandActive then
|
||||
@ -2482,6 +2430,7 @@ var
|
||||
i, j: Integer;
|
||||
SelectedPersistent: TSelectedControl;
|
||||
MouseDownControl: TControl;
|
||||
CompEditor: TBaseComponentEditor;
|
||||
p: types.TPoint;
|
||||
begin
|
||||
FHintTimer.Enabled := False;
|
||||
@ -2493,10 +2442,8 @@ begin
|
||||
DesignSender:=GetDesignControl(Sender);
|
||||
SenderParentForm:=GetDesignerForm(DesignSender);
|
||||
//DebugLn(['TDesigner.MouseUpOnControl DesignSender=',dbgsName(DesignSender),' SenderParentForm=',dbgsName(SenderParentForm),' ',TheMessage.XPos,',',TheMessage.YPos]);
|
||||
if (MouseDownComponent=nil) or (SenderParentForm=nil)
|
||||
or (SenderParentForm<>Form)
|
||||
or ((Selection.SelectionForm<>nil)
|
||||
and (Selection.SelectionForm<>Form)) then
|
||||
if (MouseDownComponent=nil) or (SenderParentForm=nil) or (SenderParentForm<>Form)
|
||||
or ( (Selection.SelectionForm<>nil) and (Selection.SelectionForm<>Form) ) then
|
||||
begin
|
||||
MouseDownComponent:=nil;
|
||||
MouseDownSender:=nil;
|
||||
@ -2591,22 +2538,24 @@ begin
|
||||
begin
|
||||
// new selection
|
||||
if RubberBandWasActive then
|
||||
begin
|
||||
// rubberband selection
|
||||
RubberbandSelect;
|
||||
end else
|
||||
begin
|
||||
// point selection
|
||||
PointSelect;
|
||||
RubberbandSelect // rubberband selection
|
||||
else if not (ssShift in Shift) then
|
||||
begin // point selection, select only the mouse down component
|
||||
Selection.AssignPersistent(MouseDownComponent);
|
||||
if (ssDouble in MouseDownShift) and (Selection.SelectionForm = Form) then
|
||||
begin // Double Click -> invoke 'Edit' of the component editor
|
||||
CompEditor:=TheFormEditor.GetComponentEditor(MouseDownComponent);
|
||||
Assert(Assigned(CompEditor),
|
||||
'TDesigner.MouseUpOnControl: no component editor found for '
|
||||
+MouseDownComponent.Name+':'+MouseDownComponent.ClassName);
|
||||
CompEditor.Edit;
|
||||
end;
|
||||
end;
|
||||
end
|
||||
else
|
||||
Selection.UpdateBounds;
|
||||
end else
|
||||
begin
|
||||
// create new a component on the form
|
||||
DoAddComponent;
|
||||
end;
|
||||
DoAddComponent; // create new a component on the form
|
||||
end
|
||||
else if Button=mbRight then
|
||||
begin
|
||||
@ -2615,8 +2564,8 @@ begin
|
||||
Selection.EndUpdate;
|
||||
if EnvironmentOptions.RightClickSelects
|
||||
and (not Selection.IsSelected(MouseDownComponent))
|
||||
and (Shift - [ssRight] = []) then
|
||||
PointSelect;
|
||||
and (Shift - [ssRight] = []) then // select only the mouse down component
|
||||
Selection.AssignPersistent(MouseDownComponent);
|
||||
PopupMenuComponentEditor := GetComponentEditorForSelection;
|
||||
BuildPopupMenu;
|
||||
PopupPos := Form.ClientToScreen(MouseUpPos);
|
||||
@ -2777,10 +2726,9 @@ begin
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
// rubberband sizing (selection or creation)
|
||||
begin // rubberband sizing (selection or creation)
|
||||
Selection.RubberBandBounds := Rect(MouseDownPos.X, MouseDownPos.Y,
|
||||
LastMouseMovePos.X, LastMouseMovePos.Y);
|
||||
LastMouseMovePos.X, LastMouseMovePos.Y);
|
||||
if SelectedCompClass = nil then
|
||||
Selection.RubberbandType := rbtSelection
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user