mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 23:09:16 +02:00
IDEIntf: TDefaultComponentEditor: check TControl.Action.OnExecute and TMenuItem.Action.OnExecute
git-svn-id: trunk@41418 -
This commit is contained in:
parent
047c8fcb6d
commit
384aab7b08
@ -218,7 +218,9 @@ type
|
|||||||
FFirst: TPropertyEditor;
|
FFirst: TPropertyEditor;
|
||||||
FBest: TPropertyEditor;
|
FBest: TPropertyEditor;
|
||||||
FContinue: Boolean;
|
FContinue: Boolean;
|
||||||
FPropEditCandidates: TList; // list of TPropertyEditor
|
FPropEditCandidates: TFPList; // list of TPropertyEditor
|
||||||
|
procedure AddPropEdit(Prop: TPropertyEditor);
|
||||||
|
procedure CheckActionExecute(Prop: TPropertyEditor);
|
||||||
procedure CheckEdit(Prop: TPropertyEditor);
|
procedure CheckEdit(Prop: TPropertyEditor);
|
||||||
protected
|
protected
|
||||||
procedure EditProperty(const Prop: TPropertyEditor;
|
procedure EditProperty(const Prop: TPropertyEditor;
|
||||||
@ -617,13 +619,26 @@ end;
|
|||||||
|
|
||||||
{ TDefaultComponentEditor }
|
{ TDefaultComponentEditor }
|
||||||
|
|
||||||
|
procedure TDefaultComponentEditor.AddPropEdit(Prop: TPropertyEditor);
|
||||||
|
begin
|
||||||
|
if FPropEditCandidates=nil then
|
||||||
|
FPropEditCandidates:=TFPList.Create;
|
||||||
|
FPropEditCandidates.Add(Prop);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDefaultComponentEditor.CheckActionExecute(Prop: TPropertyEditor);
|
||||||
|
begin
|
||||||
|
AddPropEdit(Prop);
|
||||||
|
if (CompareText(Prop.GetName,'OnExecute')=0)
|
||||||
|
and (Prop is TMethodPropertyEditor) then
|
||||||
|
FBest:=Prop;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TDefaultComponentEditor.CheckEdit(Prop: TPropertyEditor);
|
procedure TDefaultComponentEditor.CheckEdit(Prop: TPropertyEditor);
|
||||||
begin
|
begin
|
||||||
|
AddPropEdit(Prop);
|
||||||
if FContinue then
|
if FContinue then
|
||||||
EditProperty(Prop, FContinue);
|
EditProperty(Prop, FContinue);
|
||||||
if FPropEditCandidates=nil then
|
|
||||||
FPropEditCandidates:=TList.Create;
|
|
||||||
FPropEditCandidates.Add(Prop);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDefaultComponentEditor.EditProperty(const Prop: TPropertyEditor;
|
procedure TDefaultComponentEditor.EditProperty(const Prop: TPropertyEditor;
|
||||||
@ -647,7 +662,7 @@ begin
|
|||||||
if Assigned(FBest) then
|
if Assigned(FBest) then
|
||||||
BestName := FBest.GetName;
|
BestName := FBest.GetName;
|
||||||
// event priority is hardcoded:
|
// event priority is hardcoded:
|
||||||
// first priority has OnCreate, then OnClick and OnChange is the last
|
// first priority has FBestEditEvent (default: OnCreate), then OnClick and OnChange is the last
|
||||||
if CompareText(PropName, FBestEditEvent) = 0 then
|
if CompareText(PropName, FBestEditEvent) = 0 then
|
||||||
ReplaceBest
|
ReplaceBest
|
||||||
else
|
else
|
||||||
@ -688,24 +703,39 @@ procedure TDefaultComponentEditor.Edit;
|
|||||||
var
|
var
|
||||||
PropertyEditorHook: TPropertyEditorHook;
|
PropertyEditorHook: TPropertyEditorHook;
|
||||||
NewLookupRoot: TPersistent;
|
NewLookupRoot: TPersistent;
|
||||||
|
|
||||||
|
function TryAction(Action: TBasicAction): boolean;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
if Action=nil then exit;
|
||||||
|
GetPersistentProperties(Action,tkMethods,PropertyEditorHook,@CheckActionExecute,nil);
|
||||||
|
if FBest=nil then exit;
|
||||||
|
FBest.Edit;
|
||||||
|
Result:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
PropertyEditorHook:=nil;
|
PropertyEditorHook:=nil;
|
||||||
if not GetHook(PropertyEditorHook) then exit;
|
if not GetHook(PropertyEditorHook) then exit;
|
||||||
NewLookupRoot:=GetLookupRootForComponent(Component);
|
NewLookupRoot:=GetLookupRootForComponent(Component);
|
||||||
if not (NewLookupRoot is TComponent) then exit;
|
if not (NewLookupRoot is TComponent) then exit;
|
||||||
GetDesigner.SelectOnlyThisComponent(Component);
|
|
||||||
FContinue := True;
|
|
||||||
FFirst := nil;
|
FFirst := nil;
|
||||||
FBest := nil;
|
FBest := nil;
|
||||||
try
|
try
|
||||||
GetPersistentProperties(Component,tkAny,PropertyEditorHook,@CheckEdit,nil);
|
GetDesigner.SelectOnlyThisComponent(Component);
|
||||||
if FContinue
|
if (Component is TControl)
|
||||||
then begin
|
and TryAction(TControl(Component).Action) then
|
||||||
if Assigned(FBest) then
|
exit;
|
||||||
FBest.Edit
|
if (Component is TMenuItem)
|
||||||
else if Assigned(FFirst) then
|
and TryAction(TMenuItem(Component).Action) then
|
||||||
FFirst.Edit;
|
exit;
|
||||||
end;
|
FContinue := True;
|
||||||
|
GetPersistentProperties(Component,tkMethods,PropertyEditorHook,@CheckEdit,nil);
|
||||||
|
if not FContinue then exit;
|
||||||
|
if Assigned(FBest) then
|
||||||
|
FBest.Edit
|
||||||
|
else if Assigned(FFirst) then
|
||||||
|
FFirst.Edit;
|
||||||
finally
|
finally
|
||||||
FFirst := nil;
|
FFirst := nil;
|
||||||
FBest := nil;
|
FBest := nil;
|
||||||
|
Loading…
Reference in New Issue
Block a user