THYUpdateableController

Overview

The THYUpdateableController class provides a batch mechanism to manage all sets of menu items, menus, toolbars etc. that are added to the host by plugins.

Use Case

You should not use this class directly, to manually manage menus or toolbars in your plugins, you can use the menu or toolbar controllers. For example:

const
  // Needed to group all the controls this plugin builds
  PluginUpdates : TGUID = '{6513A5C3-2EEF-4CAF-A43D-42A89C18EEF7}';

procedure TTextEditorPlugin.HYVisualPluginSetHost(const Sender: IHYVCLHostAware;
  const aHost: IHYVCLHost);
var
  MenuItem: IHYVCLMenuItem;
begin
  if aHost.MenuController <> nil then
    with aHost.MenuController do try
      BeginUpdate(PluginUpdates);

      MenuItem := Items.InsertMenu(1, 'Edit');
      MenuItem.Add(copyAction);
      MenuItem.Add(paseAction);
    finally
      EndUpdate(PluginUpdates);
    end;
end;

procedure TTextEditorPlugin.HYVisualPluginDestroy(Sender: TObject);
begin
  if Host.MenuController <> nil then
    Host.MenuController.DeleteUpdates(PluginUpdates);
end;

Note: You can read about menu and toolbar usage in the Hydra framework in this article. Please also look at the Actions sample shipped with Hydra to see menu and toolbar merging in action.

Location


Instance Methods


constructor Create  override

Creates a new instance of the class.

constructor Create(aOwner: TComponent)

Parameters:

  • aOwner: Reference to the owner object.

AddReference  protected

Supplying AddReference calls within BeginUpate and EndUpdate pairs allows the subsequent deletion of all added items via a single call to DeleteUpdates.

procedure AddReference(const anItem: IHYVCLObjectReference)

Parameters:

  • anItem: Reference to an object.

BeginUpdate  protected virtual

Calls BeginUpdate prior to call(s) to AddReference. Each BeginUpdate must have an associated EndUpdate.

Items added by AddReference can subsequently be removed by a single call to DeleteUpdates.

procedure BeginUpdate(const aGUID: TGUID)

Parameters:

  • aGUID: Unique identifier of the session.

DeleteUpdates  protected virtual

DeleteUpdates removes all items added to the host's menu and toolbars via AddReference calls.

procedure DeleteUpdates(const aGUID: TGUID)

Parameters:

  • aGUID: Unique identifier of the session.

EndUpdate  protected virtual

Calls EndUpdate following call(s) to AddReference preceded by BeginUpdate.

procedure EndUpdate(const aGUID: TGUID)

Parameters:

  • aGUID: Unique identifier of the session.

GetIsUpdating  protected

Returns the value which indicates whether controller is being updated.

function GetIsUpdating: Boolean

GetUpdateCount  protected

Returns the number of processed updates.

function GetUpdateCount(const aGUID: TGUID): Integer

Parameters:

  • aGUID: Unique identifier of the session.