mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-06 20:18:19 +02:00
IdeIntf: Create proper name for Constraints.OnChange handler in Object Inspector. Issue #29562.
git-svn-id: trunk@52192 -
This commit is contained in:
parent
a9f11cacba
commit
2355da2c35
@ -1537,6 +1537,8 @@ begin
|
|||||||
try
|
try
|
||||||
if Edit=oiqeShowValue then
|
if Edit=oiqeShowValue then
|
||||||
CurRow.Editor.ShowValue
|
CurRow.Editor.ShowValue
|
||||||
|
else if (FSelection.Count > 0) and (FSelection[0] is TComponent) then
|
||||||
|
CurRow.Editor.Edit(TComponent(FSelection[0]))
|
||||||
else
|
else
|
||||||
CurRow.Editor.Edit;
|
CurRow.Editor.Edit;
|
||||||
finally
|
finally
|
||||||
|
@ -289,6 +289,7 @@ type
|
|||||||
private
|
private
|
||||||
FOnSubPropertiesChanged: TNotifyEvent;
|
FOnSubPropertiesChanged: TNotifyEvent;
|
||||||
FPropertyHook: TPropertyEditorHook;
|
FPropertyHook: TPropertyEditorHook;
|
||||||
|
FOwnerComponent: TComponent;
|
||||||
FPropCount: Integer;
|
FPropCount: Integer;
|
||||||
FPropList: PInstPropList;
|
FPropList: PInstPropList;
|
||||||
function GetPrivateDirectory: ansistring;
|
function GetPrivateDirectory: ansistring;
|
||||||
@ -302,7 +303,10 @@ type
|
|||||||
procedure Deactivate; virtual;
|
procedure Deactivate; virtual;
|
||||||
function AllEqual: Boolean; virtual;
|
function AllEqual: Boolean; virtual;
|
||||||
function AutoFill: Boolean; virtual;
|
function AutoFill: Boolean; virtual;
|
||||||
procedure Edit; virtual; // called when clicking on OI property button or double clicking on value
|
// Called when clicking on OI property button or double clicking on value.
|
||||||
|
procedure Edit; virtual;
|
||||||
|
// Needed for method Contraints.OnChange etc.
|
||||||
|
procedure Edit(AOwnerComponent: TComponent);
|
||||||
procedure ShowValue; virtual; // called when Ctrl-Click on value
|
procedure ShowValue; virtual; // called when Ctrl-Click on value
|
||||||
function GetAttributes: TPropertyAttributes; virtual;
|
function GetAttributes: TPropertyAttributes; virtual;
|
||||||
function IsReadOnly: boolean; virtual;
|
function IsReadOnly: boolean; virtual;
|
||||||
@ -612,7 +616,7 @@ type
|
|||||||
function GetValue: ansistring; override;
|
function GetValue: ansistring; override;
|
||||||
procedure GetValues(Proc: TGetStrProc); override;
|
procedure GetValues(Proc: TGetStrProc); override;
|
||||||
procedure SetValue(const NewValue: ansistring); override;
|
procedure SetValue(const NewValue: ansistring); override;
|
||||||
function GetFormMethodName: shortstring; virtual;
|
function GetFormMethodName: shortstring;
|
||||||
function GetTrimmedEventName: shortstring;
|
function GetTrimmedEventName: shortstring;
|
||||||
class function GetDefaultMethodName(Root, Component: TComponent;
|
class function GetDefaultMethodName(Root, Component: TComponent;
|
||||||
const RootClassName, ComponentName, PropName: shortstring): shortstring;
|
const RootClassName, ComponentName, PropName: shortstring): shortstring;
|
||||||
@ -1354,7 +1358,7 @@ type
|
|||||||
Shift: TShiftState; X, Y: Integer);
|
Shift: TShiftState; X, Y: Integer);
|
||||||
// persistent objects
|
// persistent objects
|
||||||
function GetObject(const aName: ShortString): TPersistent;
|
function GetObject(const aName: ShortString): TPersistent;
|
||||||
function GetObjectName(Instance: TPersistent): ShortString;
|
function GetObjectName(Instance: TPersistent; AOwnerCompName: String): String;
|
||||||
procedure GetObjectNames(TypeData: PTypeData; const Proc: TGetStrProc);
|
procedure GetObjectNames(TypeData: PTypeData; const Proc: TGetStrProc);
|
||||||
procedure ObjectReferenceChanged(Sender: TObject; NewObject: TPersistent);
|
procedure ObjectReferenceChanged(Sender: TObject; NewObject: TPersistent);
|
||||||
// modifing
|
// modifing
|
||||||
@ -2370,6 +2374,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TPropertyEditor.Edit(AOwnerComponent: TComponent);
|
||||||
|
begin
|
||||||
|
FOwnerComponent := AOwnerComponent;
|
||||||
|
Edit;
|
||||||
|
FOwnerComponent := Nil;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TPropertyEditor.ShowValue;
|
procedure TPropertyEditor.ShowValue;
|
||||||
begin
|
begin
|
||||||
|
|
||||||
@ -4336,9 +4347,24 @@ begin
|
|||||||
Result := 2*MaxIdentLength+1; // clasname.methodname
|
Result := 2*MaxIdentLength+1; // clasname.methodname
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TrimNonAscii(const Txt: String): String;
|
||||||
|
// ToDo: Find a similar function from FPC libs and use it instead.
|
||||||
|
var
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
Result := Txt;
|
||||||
|
for I := Length(Result) downto 1 do
|
||||||
|
if not (
|
||||||
|
(Result[I] in ['a'..'z', 'A'..'Z', '_']) or
|
||||||
|
(I > 1) and (Result[I] in ['0'..'9'])
|
||||||
|
)
|
||||||
|
then
|
||||||
|
System.Delete(Result, I, 1);
|
||||||
|
end;
|
||||||
|
|
||||||
function TMethodPropertyEditor.GetFormMethodName: shortstring;
|
function TMethodPropertyEditor.GetFormMethodName: shortstring;
|
||||||
// returns the default name for a new method
|
// returns the default name for a new method
|
||||||
var I: Integer;
|
var
|
||||||
Root: TPersistent;
|
Root: TPersistent;
|
||||||
begin
|
begin
|
||||||
Result:='';
|
Result:='';
|
||||||
@ -4354,18 +4380,12 @@ begin
|
|||||||
if Root is TFrame then
|
if Root is TFrame then
|
||||||
Result := 'Frame'
|
Result := 'Frame'
|
||||||
else
|
else
|
||||||
begin
|
|
||||||
Result := ClassNameToComponentName(PropertyHook.GetRootClassName);
|
Result := ClassNameToComponentName(PropertyHook.GetRootClassName);
|
||||||
end;
|
end
|
||||||
end else begin
|
else begin
|
||||||
Result := PropertyHook.GetObjectName(GetComponent(0));
|
Assert(Assigned(FOwnerComponent),
|
||||||
for I := Length(Result) downto 1 do
|
'TMethodPropertyEditor.GetFormMethodName: FOwnerComponent not assigned.');
|
||||||
if
|
Result := TrimNonAscii(PropertyHook.GetObjectName(GetComponent(0), FOwnerComponent.Name));
|
||||||
not (
|
|
||||||
(Result[I] in ['a'..'z', 'A'..'Z', '_']) or
|
|
||||||
(I > 1) and (Result[I] in ['0'..'9']))
|
|
||||||
then
|
|
||||||
System.Delete(Result, I, 1);
|
|
||||||
end;
|
end;
|
||||||
if Result = '' then begin
|
if Result = '' then begin
|
||||||
{raise EPropertyError.CreateRes(@SCannotCreateName);}
|
{raise EPropertyError.CreateRes(@SCannotCreateName);}
|
||||||
@ -6059,7 +6079,8 @@ begin
|
|||||||
Result:=TPropHookGetObject(FHandlers[htGetObject][i])(aName);
|
Result:=TPropHookGetObject(FHandlers[htGetObject][i])(aName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TPropertyEditorHook.GetObjectName(Instance: TPersistent): ShortString;
|
function TPropertyEditorHook.GetObjectName(Instance: TPersistent;
|
||||||
|
AOwnerCompName: String): String;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
@ -6073,11 +6094,8 @@ begin
|
|||||||
Result:=TComponent(Instance).Name
|
Result:=TComponent(Instance).Name
|
||||||
else if instance is TCollectionItem then
|
else if instance is TCollectionItem then
|
||||||
Result:=TCollectionItem(Instance).GetNamePath
|
Result:=TCollectionItem(Instance).GetNamePath
|
||||||
else begin
|
else
|
||||||
Result:=Instance.ClassName;
|
Result:=AOwnerCompName + ClassNameToComponentName(Instance.ClassName);
|
||||||
if (Length(Result) > 1) and (Result[1] in ['t', 'T']) then
|
|
||||||
system.Delete(Result, 1, 1);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPropertyEditorHook.GetObjectNames(TypeData: PTypeData;
|
procedure TPropertyEditorHook.GetObjectNames(TypeData: PTypeData;
|
||||||
|
Loading…
Reference in New Issue
Block a user