SDLMenus

TSDLMenuItem

TSDLMenuItem describes the properties of an item in a menu. It is a descendant of TSDLComponent. Properties are:

property Items[Index: Integer]: TSDLMenuItem read GetItem; default;
Lists the menu items in the submenu of the menu item.
property Caption: string read FCaption write FCaption;
Specifies the text of the menu item.
property Checked: Boolean read FChecked write SetChecked default False;
Specifies whether a check mark should appear beside the Caption.
property GroupIndex: Byte read FGroupIndex write SetGroupIndex default 0;
This property is used to define groups of menu items that act like radio buttons. It also has to be larger than 0 for Checked property to have any funcionality.
property MenuIndex: Integer read FMenuIndex;
Indicates the index of the menu item within its parent menu.
property RadioItem: Boolean read FRadioItem write SetRadioItem default False;
Specifies whether the menu item is mutually exclusive with other menu items in its group.

It has three new methods:

function Add(const ACaption: string; AOnClick: TSDLMouseClickEvent): Integer;
Adds one menu item to the end of the Items property array with specified caption and onclick event.
procedure Delete(Index: Integer);
Removes a menu item from the Items property array.
function Find(const ACaption: string): TSDLMenuItem;
Locates a menu item in the Items property array given its caption.
function Insert(Index: Integer;const ACaption: string): Integer;
Inserts a menu item into a specified position in the Items array.

TSDLMenuBase

TSDLMenuBase is a base class for TSDLPopupMenu and TSDLMenu. It is a descendant of TSDLStdControl. There is one new property:

property Items[Index: Integer]: TSDLMenuItem read GetItem; default;
Describes the elements of the menu.

It has five new methods:

procedure AddItems(AItems: TStrings);
Adds TSDLMenuItems with captions given in string list. You can specify subitems of an item if you put them under that item but add one tab char before them.
function Add(const ACaption: string; AOnClick: TSDLMouseClickEvent): Integer;
Adds one menu item to the end of the Items property array with specified caption and onclick event.
procedure Delete(Index: Integer);
Removes a menu item from the Items property array.
function Find(const ACaption: string): TSDLMenuItem;
Locates a menu item in the Items property array given its caption.
function Insert(Index: Integer;const ACaption: string): Integer;
Inserts a menu item into a specified position in the Items array.

TSDLPopupMenu

TSDLPopupMenu encapsulates the properties, methods, and events of a pop-up menu. It is a descendant of TSDLMenuBase. It has no new properties/methods.

TSDLMenu

TSDLMenu is a base class for TSDLPopupMenu and TSDLMenu. It is a descendant of TSDLMenuBase. There are no new properties and one new method:

procedure UpdateItems;
You should call this whenever you change its items. It will set appropriate position and dimensions of every item.