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