Public Member Functions
MenuItem Class Reference

Detailed Description

The MenuItem object represents an individual item on a custom menu.

Here are some of the features:

A menu item can be defined as a standard menu item on which you can attach a command or callback function

Note:
If for some reasons you assign both a command and a callback to your menu item, the command will have precedence over the callback when the menu item is selected).

You can also create a menu item as a separator or as a sub menu. See the Menu object documentation for more details about adding menu items to a custom menu.

Since:
4.0

#include <xsi_menuitem.h>

Inheritance diagram for MenuItem:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 MenuItem ()
 ~MenuItem ()
 MenuItem (const CRef &in_ref)
 MenuItem (const MenuItem &in_obj)
bool IsA (siClassID in_ClassID) const
siClassID GetClassID () const
MenuItemoperator= (const MenuItem &in_obj)
MenuItemoperator= (const CRef &in_ref)
CStatus PutCallback (const CString &in_strCallback)
CString GetCallback () const
CStatus PutCommand (const CString &in_strCommand)
siMenuItemStyle GetStyle () const
CStatus PutFilter (const CString &in_strFilter)
CRef GetFilter () const
bool IsEnabled ()
CStatus PutEnabled (bool in_bFlag)
bool IsChecked () const
CStatus PutChecked (bool in_bFlag)

Constructor & Destructor Documentation

MenuItem ( )

Default constructor.

~MenuItem ( )

Default destructor.

MenuItem ( const CRef in_ref)

Constructor.

Parameters:
in_refconstant reference object.
MenuItem ( const MenuItem in_obj)

Copy constructor.

Parameters:
in_objconstant class object.

Member Function Documentation

bool IsA ( siClassID  in_ClassID) const [virtual]

Returns true if a given class type is compatible with this API class.

Parameters:
in_ClassIDclass type.
Returns:
true if the class is compatible, false otherwise.

Reimplemented from UIObject.

Reimplemented in Menu.

siClassID GetClassID ( ) const [virtual]

Returns the type of the API class.

Returns:
The class type.

Reimplemented from UIObject.

Reimplemented in Menu.

MenuItem& operator= ( const MenuItem in_obj)

Creates an object from another object. The newly created object is set to empty if the input object is not compatible.

Parameters:
in_objconstant class object.
Returns:
The new MenuItem object
MenuItem& operator= ( const CRef in_ref)

Creates an object from a reference object. The newly created object is set to empty if the input reference object is not compatible.

Parameters:
in_refconstant class object.
Returns:
The new MenuItem object.

Reimplemented from UIObject.

Reimplemented in Menu.

CStatus PutCallback ( const CString in_strCallback)

Sets the callback function for this menu item. The callback function is called when the item is selected and is executed by XSI as a single undo event. You can always undo/redo the action of a menu item callback function provided your function calls undoable commands or object model methods. The callback function must have the following signature:

    CStatus MyFunction( const XSI::CRef& in_context )
in_context
The Context object containing the MenuItem object for which the function is called.

The menu item that points to a callback has the following caption:

 item_name [origin] 

where item_name is the name of the menu item and origin the origin of the callback ([u] for user, [w] for workgroup).

Parameters:
in_strCallbackCallback function name.
Returns:
CStatus::OK success
CStatus::Fail failure
CString GetCallback ( ) const

Returns the callback function for this menu item.

Returns:
The callback function name.
CStatus PutCommand ( const CString in_strCommand)

Sets the command for this menu item. You can attach any native or custom commands you want to a menu item. If your menu is attached to a contextual menu and one of your command's arguments takes the selected objects by default, then the current selected object(s) is passed into your command. The target object under the cursor is also passed in as part of the selected objects. However if no objects are selected then only the target is passed in.

When a command is attached to a menu item, the caption is set as follows:

 item_name [origin] hotkey 

where item_name is the name of the menu item, origin the origin of the command ([u] for user, [w] for workgroup) and hotkey the hotkey associated with the command.

The menu item will be greyed out if the command is disabled.

Parameters:
in_strCommandCommand name.
Returns:
CStatus::OK success
CStatus::Fail failure
siMenuItemStyle GetStyle ( ) const

Returns the style of this menu item.

Returns:
The menu item style.
CStatus PutFilter ( const CString in_strFilter)

Sets the filter for this menu item. XSI uses the filter for validating the menu item or an entire menu against the target or selected objects before it gets displayed.

If the filter criteria are not satisfied then the menu item is greyed out. Menus are removed if attached to a contextual menu.

Parameters:
in_strFilterFilter name.
Returns:
CStatus::OK success
CStatus::Fail failure
Since:
5.0

Reimplemented in Menu.

CRef GetFilter ( ) const

Returns the filter attached to this menu item.

Returns:
Reference to the Filter object.
Since:
5.0
bool IsEnabled ( )

Returns true if the menu item is enabled.

Returns:
True if enabled.
Since:
5.0
CStatus PutEnabled ( bool  in_bFlag)

Enables or disables a menu item. Menu objects can also be enabled or disabled which means all menu items defined in a menu are affected. This property is typically used for updating a menu item based on a specific context. Enabled by default.

Parameters:
in_bFlagTrue enables the menu item, false disables it.
Returns:
CStatus::OK Success.
CStatus::Fail Failure.
Since:
5.0
bool IsChecked ( ) const

Returns true if the menu item is checked.

Returns:
True if checked.
Since:
10.0 (2012)
CStatus PutChecked ( bool  in_bFlag)

Checks or unchecks a menu item. Unchecked by default.

Parameters:
in_bFlagTrue checks the menu item, false unchecks it.
Returns:
CStatus::OK Success.
CStatus::Fail Failure.
Since:
10.0 (2012)

The documentation for this class was generated from the following file: