- Main Page
- Related Pages
- Modules
- Classes
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Protected Member Functions

# MPxContextCommand Class Reference
OpenMayaUI - API module for user interface | Proxy classes

Search for all occurrences

## Detailed Description

Base class for context creation commands.

This is the base class for context creation commands.

The purpose of this command class is to create instances of user contexts derived from MPxContext, and to allow the MEL programmer to edit and query various properties of the context related to this command.

The user will derive off of this class and override the makeObj method which will be called when this command is invoked in Maya.

The context command is registered in Maya using MFnPlugin::registerContextCommand

Examples:

  componentScaleManip.cpp, customAttrManip.cpp, helixTool.cpp, lassoTool.cpp, marqueeTool.cpp, meshRemapTool.h, meshReorderTool.h, moveManip.cpp, moveNumericTool.cpp, moveTool.cpp, rotateManip.cpp, and surfaceBumpManip.cpp.

`#include <MPxContextCommand.h>`

Inheritance diagram for MPxContextCommand:
[legend]

List of all members.

## Public Member Functions
| MPxContextCommand ()
| Class constructor.
virtual | ~MPxContextCommand ()
| Class destructor.
virtual MStatus | doEditFlags ()
| This method is called when the command is called in edit mode.
virtual MStatus | doQueryFlags ()
| This method is called when the command is called in query mode.
virtual MPxContext * | makeObj ()
| This function is used to instantiate a proxy context.
virtual MStatus | appendSyntax ()
| This method should be overridden to append syntax to the context command.
MStatus | setResult (bool result)
| This method should be called when the result of the context command is a boolean.
MStatus | setResult (int result)
| This method should be called when the result of the context command is an integer.
MStatus | setResult (double result)
| This method should be called when the result of the context command is a double.
MStatus | setResult (const MString &result)
| This method should be called when the result of the context command a string.
## Static Public Member Functions
static const char * | className ()
| Returns the name of this class.
## Protected Member Functions
MSyntax | syntax (MStatus *ReturnStatus=NULL) const
| USE _syntax() IN SCRIPT.
MArgParser | parser (MStatus *ReturnStatus=NULL) const
| USE _parser() IN SCRIPT.

## Member Function Documentation

MStatus doEditFlags | ( |  | ) | `[virtual]`

Search for all occurrences

This method is called when the command is called in edit mode.

This method should be overridden by context commands to determine which edit flags are set in conjunction with the argument parser for this command. The argument parser for this command can be obtained by calling the parser method. If the command is called with both the edit flag and the query flag, then the query flag will be ignored.

Returns:
  - MS::kSuccess operation successful
  - MS::kFailure operation failed

Examples:
  helixTool.cpp.

MStatus doQueryFlags | ( |  | ) | `[virtual]`

Search for all occurrences

This method is called when the command is called in query mode.

This method should be overridden by context commands to determine which query flags are set in conjunction with the argument parser for this command. The argument parser for this command can be obtained by calling the parser method. If the command is called with both the edit flag and the query flag, then the query flag will be ignored.

Returns:
  - MS::kSuccess operation successful
  - MS::kFailure operation failed

Examples:
  helixTool.cpp.

MPxContext * makeObj | ( |  | ) | `[virtual]`

Search for all occurrences

This function is used to instantiate a proxy context.

In your derived class, declare this function:

        MPxContext * derivedClass::makeObj() {
            return new userContextClass;
        }

where userContextClass is derived from MPxContext.

Returns:
  - Returns a pointer to an MPxContext.

Reimplemented in MTemplateContextCommand< ContextCommandName, ContextCommandClass, ContextClass >.

Examples:
  componentScaleManip.cpp, customAttrManip.cpp, helixTool.cpp, lassoTool.cpp, marqueeTool.cpp, meshRemapTool.h, meshReorderTool.h, moveManip.cpp, moveNumericTool.cpp, moveTool.cpp, rotateManip.cpp, and surfaceBumpManip.cpp.

MStatus appendSyntax | ( |  | ) | `[virtual]`

Search for all occurrences

This method should be overridden to append syntax to the context command.

The syntax object can be obtained by calling the syntax method. The following flags cannot be used as user-defined flags as they are reserved for edit and query: "-e", "-edit", "-q", "-query".

Returns:
  - MS::kSuccess operation successful
  - MS::kFailure operation failed

Examples:
  helixTool.cpp.

MStatus setResult | ( | bool | result | ) |

Search for all occurrences

This method should be called when the result of the context command is a boolean.

Parameters:

  [in] | result | the boolean result

Returns:
  - MS::kSuccess operation successful
  - MS::kFailure operation failed

MStatus setResult | ( | int | result | ) |

Search for all occurrences

This method should be called when the result of the context command is an integer.

Parameters:

  [in] | result | the integer result

Returns:
  - MS::kSuccess operation successful
  - MS::kFailure operation failed

MStatus setResult | ( | double | result | ) |

Search for all occurrences

This method should be called when the result of the context command is a double.

Parameters:

  [in] | result | the double result

Returns:
  - MS::kSuccess operation successful
  - MS::kFailure operation failed

MStatus setResult | ( | const MString & | result | ) |

Search for all occurrences

This method should be called when the result of the context command a string.

Parameters:

  [in] | result | the string result

Returns:
  - MS::kSuccess operation successful
  - MS::kFailure operation failed

const char * className | ( |  | ) | `[static]`

Search for all occurrences

Returns the name of this class.

Returns:
  Name of this class.

MSyntax syntax | ( | MStatus * | ReturnStatus = `NULL` | ) | const`[protected]`

Search for all occurrences

USE _syntax() IN SCRIPT.

This method returns the syntax object of this context command.

From an overridden version of the appendSyntax method you may append to the syntax object.

Parameters:

  [out] | ReturnStatus | return status

Returns:
  The syntax object

Status Codes:
  - MS::kSuccess operation successful
  - MS::kFailure operation failed

MArgParser parser | ( | MStatus * | ReturnStatus = `NULL` | ) | const`[protected]`

Search for all occurrences

USE _parser() IN SCRIPT.

This method returns the argument parser of this context command.

The argument parser can be used in the overridden versions of doEditFlags and doQueryFlags to determine which flags are set.

Parameters:

  [out] | ReturnStatus | return status

Returns:
  The argument parser

Status Codes:
  - MS::kSuccess operation successful
  - MS::kFailure operation failed

MPxContextCommand MPxContextCommand MPxContextCommand MPxContextCommand MPxContextCommand MPxContextCommand MPxContextCommand MPxContextCommand MPxContextCommand MPxContextCommand
MPxContextCommand MPxContextCommand MPxContextCommand MPxContextCommand MPxContextCommand MPxContextCommand MPxContextCommand MPxContextCommand MPxContextCommand MPxContextCommand