## Menu Item Callbacks

### Description

Callback function fired when a user clicks a menu item.

Menu item callbacks are added to a menu item with Menu.AddCallbackItem.

Use this callback to define a special function that will execute when the user activates the associated callback menu item. For example, you could implement a function that modifies the current layout or changes some user preferences.

This differs from a command menu item associated to a custom command that you have defined in the same plug-in in that a callback function does not get added to the Softimage command map.

Tip | This callback is fired every time the menu callback function is invoked.

### Applies To

Menu items added to a menu item with Menu.AddCallbackItem.

### Syntax

    public class <menu_name>
    {
            public bool <menu-item_callback_name>( Context in_context )
            {
                    ...
            }
    }

    CStatus <menu-item_callback_name>( CRef& in_context )
    {
            ...
    }

    function <menu-item_callback_name>( in_context )
    {
            ...
    }

    def <menu-item_callback_name>( in_context ):
            ...

    Function <menu-item_callback_name>( in_context )
            ...
    End Function

    sub <menu-item_callback_name>
    {
            my $in_context = shift;
    }

<menu-item_callback_name> is the name specified in the call to Menu.AddCallbackItem, with any spaces converted to underscores.

### Parameters

Parameter | Language | Type | Description
--- | --- | --- | ---
in_context | Scripting and C# | Context | Context.Source returns the MenuItem.
| C++ | CRef& | A reference to the Context object. Context::GetSource returns the MenuItem.

### Context Attributes

For most context menus, the Target attribute contains the selected objects and the object under the mouse pointer.

For regular menus (except for the File menu in the Plug-in Manager), the Target attribute is not set).

Attribute | Menus | Description
--- | --- | ---
Target | 3D View and SE context menus | Scripting and C# XSICollection containing the selected objects and the object under the cursor. C++ CValue containing a CValueArray. The array contains the selected objects and the object under the cursor.
| Animation Mixer menus | The View object for the Animation Mixer.
| FCurve Editor menus | The View object for the FCurve Editor.
| Property Editor context menu | The object whose parameters are displayed on the property page (for example, a KinematicState object for the Global Transform property page).
| Plug-in Manager and menus (context and normal menus) Workgroup Manager File menu | The View object for the Plug-in Manager.
| Script Editor context menus | History pane The selected text or, if no text is selected, the current line. Editing pane The View object for the script editor.
| Schematic View and View Context menus | The Target attribute contains the Schematic View object.
| Schematic Node context menus | Scripting and C# XSICollection containing the view object and the object under the cursor. C++ CValue containing a CValueArray. The array contains the view object and the object under the cursor.
| Scene Layer Manager menus | The View object for the Scene Layer Manager.
| Scene Layer Manager context menus | Scripting and C# Layer containing the layer object under the cursor. C++ Layer containing the layer object under the cursor.
| Material Manager menus | The View object for the Material Manager.
| Shader Code Editor menus | The View object for the Shader Code Editor.

### See Also

- Init (Menu)
- Menu Callbacks
- Standard and Contextual Menus