[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Menus' (#lcl)

# TMenuItem.SetAction

Sets the value for the Action property.

## Declaration

Source position: menus.pp line 246

`protected procedure TMenuItem.SetAction(`
`NewAction: TBasicAction`
`);`

## Arguments

`NewAction` |  | New value for the Action property.

## Description

SetAction ensures that the ActionLink property is updated when the new property value is applied to the control.

When NewAction contains Nil, the class instance in ActionLink is freed and Nil'd.

Otherwise, GetActionLinkClass is called to create a new action link class instance for the ActionLink member. Its Action property is set to the value in NewAction, and its OnChange event handler is set to the DoActionChange method. ActionChange is called to synchronize property values in the class instance to the values in the Action.

## See also

TMenuItem.Action |  | Action is the default action associated with the menu item.
TMenuItem.ActionLink |  | Contains the link to the Action for the menu item.
TMenuItem.ActionChange |  | Changes the action for the menu item using the value specified in Sender.
TMenuItem.GetActionLinkClass |  | Gets the class reference used to create an action link for the class.