THYObjectReference
Overview
The THYObjectReference base class implements the IHYVCLObjectReference interface and provides basic functionality needed to access an object wrapped by other objects, such as user interface items.
Use Case
You do not need to use this class directly, instead, you can use the IHYVCLObjectReference interface to access an underlying object. For example:
procedure TTextEditorPlugin.HYPluginControlsRepository1AfterMergeMenuItems(
Sender: THYPluginControlsRepository; const aHost: IHYVCLHost;
const anUpdateID: TGUID);
var
FileMenu : IHYVCLMenuItem;
begin
if (Host.MenuController=NIL) then Exit;
FileMenu := Host.MenuController.Items.MenuItemByCaption('File');
((FileMenu as IHYVCLObjectReference).RefObject as TMenuItem).Caption := 'New Caption';
end;
Alternatively, you could set the properties using Properties
, with code like this:
(FileMenu as IHYVCLObjectReference).Properties['Caption'] := 'New Caption';
Location
- Unit: Hydra.VCL.UserInterface.pas
- Ancestry: TInterfacedObject | THYObjectReference
Instance Methods
constructor Create reintroduce virtual
Creates a new instance of the class.
constructor Create(anObject: TObject; OwnsObject: Boolean)
Parameters:
- anObject: Object that is wrapped by this class, if
anObject
is nil, an EHYException is raised. - OwnsObject: If set to true, the referenced object will be freed when this class is destroyed.
DestroyObject protected
Destroys the referenced object.
procedure DestroyObject
GetProperty protected
Retrieves the value of the published property of the referenced object.
function GetProperty(const aName: string): variant
Parameters:
- aName: Name of the property.
GetRefObject protected
Gets referenced object.
function GetRefObject: TObject
SetProperty protected
Sets the value of the published property of the referenced object.
procedure SetProperty(const aName: string; const aPropertyValue: variant)
Parameters:
- aName: Name of the property.
- aPropertyValue: Value of the property.