IHYVCLMenuItem

Overview

IHYVCLMenuItem is an interface that represents menu items for the Hydra framework. Inside the Hydra framework, this interface is used to provide support for menu merging between host and plugins.

You can read about menu and toolbar merging in this article.

Use Case

You may use this interface to manipulate menu items, as an example, the following code demonstrates how you can manually add menu items into your host application menu:

procedure TTextEditor.HYPluginControlsRepository1AfterMergeMenuItems(
  Sender: THYPluginControlsRepository; const aHost: IHYVCLHost;
    const anUpdateID: TGUID);
var filemenu : IHYVCLMenuItem;
begin
  // Here, we customize manually, since the Open and
  // Save items need to go under the File menu
  if (aHost.MenuController=NIL) then Exit;
  
  filemenu := aHost.MenuController.Items.MenuItemByCaption('File');
  filemenu.Insert(0, actOpen);
  filemenu.Insert(1, actSave);
  filemenu.InsertSeparator(2);
end;

Note: Take a look at the Actions sample shipped with Hydra to see menu and toolbar merging in action.

Location


 

Action    (declared in IHYVCLControl)

Gets or sets the reference to the action associated with the control.

property Action: TBasicAction read write

Add (TBasicAction): IHYVCLMenuItem  overload

Adds a new item and fills it with information from the action object.

function Add(anAction: TBasicAction): IHYVCLMenuItem

Parameters:

  • anAction: Reference to an action object.

Add (string): IHYVCLMenuItem  overload

Adds a new item with specified caption.

function Add(const aCaption: string): IHYVCLMenuItem

Parameters:

  • aCaption: Title of the item.

AddMenu

Adds a new menu with the specified caption.

function AddMenu(const aCaption: string): IHYVCLMenuItem

Parameters:

  • aCaption: Title of the item.

AddSeparator

Adds a separator line.

function AddSeparator: IHYVCLMenuItem

Caption    (declared in IHYVCLControl)

Gets or sets the caption associated with the control.

property Caption: string read write

Count

Gets the number of subitems of the menu item.

property Count: Integer read

Delete

Deletes the menu item with the given index.

procedure Delete(Index: Integer)

Parameters:

  • Index: Index of the item.

DestroyObject    (declared in IHYVCLObjectReference)

Destroys referenced object.

procedure DestroyObject

FindMenuItem

Searches for the menu item with the given caption, if this menu item does not exist, nil is returned.

function FindMenuItem(const aCaption: string): IHYVCLMenuItem

Parameters:

  • aCaption: Caption of the item.

GetAction    (declared in IHYVCLControl)

function GetAction: TBasicAction

GetCaption    (declared in IHYVCLControl)

function GetCaption: string

GetCount

function GetCount: Integer

GetIndex    (declared in IHYVCLControl)

function GetIndex: Integer

GetItems

function GetItems(Index: Integer): IHYVCLMenuItem

Parameters:

  • Index:

GetProperty    (declared in IHYVCLObjectReference)

function GetProperty(const aName: string): Variant

Parameters:

  • aName:

GetRefObject    (declared in IHYVCLObjectReference)

function GetRefObject: TObject

Index    (declared in IHYVCLControl)

Gets the index associated with the control.

property Index: Integer read

Insert (Integer, TBasicAction): IHYVCLMenuItem  overload

Inserts a new item into the position specified by the anIndex parameter and fills it with information from the given action object.

function Insert(anIndex: Integer; anAction: TBasicAction): IHYVCLMenuItem

Parameters:

  • anIndex: Index of the item.
  • anAction: Reference to an action object.

Insert (Integer, string): IHYVCLMenuItem  overload

Inserts a new item with the given caption into the position specified by the anIndex parameter.

function Insert(anIndex: Integer; const aCaption: string): IHYVCLMenuItem

Parameters:

  • anIndex: Index of the item.
  • aCaption: Title of the item.

InsertMenu

Inserts a new menu with the given caption into the position specified by the anIndex parameter.

function InsertMenu(anIndex: Integer; const aCaption: string): IHYVCLMenuItem

Parameters:

  • anIndex: Index of the item.
  • aCaption: Title of the item.

InsertSeparator

Inserts a separator line into the position specified by the anIndex parameter.

function InsertSeparator(anIndex: Integer): IHYVCLMenuItem

Parameters:

  • anIndex: Index of the item.

Items

Gets reference to a menu item with specified index.

property Items[Index: Integer]: IHYVCLMenuItem read

Searches for the menu item with the given caption, if this menu item does not exists, an EHYException is raised.

function MenuItemByCaption(const aCaption: string): IHYVCLMenuItem

Parameters:

  • aCaption: Caption of the item.

Properties    (declared in IHYVCLObjectReference)

Gets or sets the value of the published properties of the referenced object with specified name.

property Properties[aName: string]: Variant read write

RefObject    (declared in IHYVCLObjectReference)

Gets a pointer to the referenced object.

property RefObject: TObject read

SetAction    (declared in IHYVCLControl)

procedure SetAction(Value: TBasicAction)

Parameters:

  • Value:

SetCaption    (declared in IHYVCLControl)

procedure SetCaption(const Value: string)

Parameters:

  • Value:

SetProperty    (declared in IHYVCLObjectReference)

procedure SetProperty(const aName: string; const aPropertyValue: Variant)

Parameters:

  • aName:
  • aPropertyValue:

 

Action    (declared in IHYVCLControl)

Gets or sets the reference to the action associated with the control.

property Action: TBasicAction read write

Caption    (declared in IHYVCLControl)

Gets or sets the caption associated with the control.

property Caption: string read write

Count

Gets the number of subitems of the menu item.

property Count: Integer read

Index    (declared in IHYVCLControl)

Gets the index associated with the control.

property Index: Integer read

Items

Gets reference to a menu item with specified index.

property Items[Index: Integer]: IHYVCLMenuItem read

Properties    (declared in IHYVCLObjectReference)

Gets or sets the value of the published properties of the referenced object with specified name.

property Properties[aName: string]: Variant read write

RefObject    (declared in IHYVCLObjectReference)

Gets a pointer to the referenced object.

property RefObject: TObject read

 

Add (TBasicAction): IHYVCLMenuItem  overload

Adds a new item and fills it with information from the action object.

function Add(anAction: TBasicAction): IHYVCLMenuItem

Parameters:

  • anAction: Reference to an action object.

Add (string): IHYVCLMenuItem  overload

Adds a new item with specified caption.

function Add(const aCaption: string): IHYVCLMenuItem

Parameters:

  • aCaption: Title of the item.

AddMenu

Adds a new menu with the specified caption.

function AddMenu(const aCaption: string): IHYVCLMenuItem

Parameters:

  • aCaption: Title of the item.

AddSeparator

Adds a separator line.

function AddSeparator: IHYVCLMenuItem

Delete

Deletes the menu item with the given index.

procedure Delete(Index: Integer)

Parameters:

  • Index: Index of the item.

DestroyObject    (declared in IHYVCLObjectReference)

Destroys referenced object.

procedure DestroyObject

FindMenuItem

Searches for the menu item with the given caption, if this menu item does not exist, nil is returned.

function FindMenuItem(const aCaption: string): IHYVCLMenuItem

Parameters:

  • aCaption: Caption of the item.

GetAction    (declared in IHYVCLControl)

function GetAction: TBasicAction

GetCaption    (declared in IHYVCLControl)

function GetCaption: string

GetCount

function GetCount: Integer

GetIndex    (declared in IHYVCLControl)

function GetIndex: Integer

GetItems

function GetItems(Index: Integer): IHYVCLMenuItem

Parameters:

  • Index:

GetProperty    (declared in IHYVCLObjectReference)

function GetProperty(const aName: string): Variant

Parameters:

  • aName:

GetRefObject    (declared in IHYVCLObjectReference)

function GetRefObject: TObject

Insert (Integer, TBasicAction): IHYVCLMenuItem  overload

Inserts a new item into the position specified by the anIndex parameter and fills it with information from the given action object.

function Insert(anIndex: Integer; anAction: TBasicAction): IHYVCLMenuItem

Parameters:

  • anIndex: Index of the item.
  • anAction: Reference to an action object.

Insert (Integer, string): IHYVCLMenuItem  overload

Inserts a new item with the given caption into the position specified by the anIndex parameter.

function Insert(anIndex: Integer; const aCaption: string): IHYVCLMenuItem

Parameters:

  • anIndex: Index of the item.
  • aCaption: Title of the item.

InsertMenu

Inserts a new menu with the given caption into the position specified by the anIndex parameter.

function InsertMenu(anIndex: Integer; const aCaption: string): IHYVCLMenuItem

Parameters:

  • anIndex: Index of the item.
  • aCaption: Title of the item.

InsertSeparator

Inserts a separator line into the position specified by the anIndex parameter.

function InsertSeparator(anIndex: Integer): IHYVCLMenuItem

Parameters:

  • anIndex: Index of the item.

Searches for the menu item with the given caption, if this menu item does not exists, an EHYException is raised.

function MenuItemByCaption(const aCaption: string): IHYVCLMenuItem

Parameters:

  • aCaption: Caption of the item.

SetAction    (declared in IHYVCLControl)

procedure SetAction(Value: TBasicAction)

Parameters:

  • Value:

SetCaption    (declared in IHYVCLControl)

procedure SetCaption(const Value: string)

Parameters:

  • Value:

SetProperty    (declared in IHYVCLObjectReference)

procedure SetProperty(const aName: string; const aPropertyValue: Variant)

Parameters:

  • aName:
  • aPropertyValue: