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

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions

# MEvent Class Reference

# OpenMayaUI - API module for user interface

Search for all occurrences

## Detailed Description

System event information.

The MEvent class is used for querying system events such as mouse presses.

Events are handled by an MPxContext derived class in which MEvents are passed and can be accessed.

Since Maya has default actions for several events, only a subset are avalaible through the API. The events that can be accessed are:

- buttonPress - mouse button press event (left & middle only)
- buttonRelease - mouse buttons release event (left & middle only)
- mouseDrag - mouse button drag event (left & middle only)
- hold - mouse button hold event (left & middle only)
- deleteEvent - delete/backspace key event
- commandCompletion - complete key event

Several modifiers for events are also accessible through the API. Modifiers are actions that occur during an event. For example, holding down the shift key while pressing a mouse button causes a button press event to occur with a shift modifier.

A modifier can be used to determine if two mouse events occur simulaneously. The second mouse event is registered as a modifier in the hold event of the first mouse button. So if you wanted to determine if both the left and middle buttons are pressed then you would query the modifier in the hold event of the first mouse button using the isModifierMiddleMouseButton() and isModifierLeftMouseButton() methods.

Examples:

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

`#include <MEvent.h>`

List of all members.

## Public Types
enum | ModifierType { shiftKey = 1<<0, controlKey = 1<<2 }
| Modifier key types. More...
enum | MouseButtonType { kLeftMouse = 1<<6, kMiddleMouse = kLeftMouse<<1 }
| Mouse button types. More...
## Public Member Functions
| MEvent ()
| Constructor.
virtual | ~MEvent ()
| Destructor.
MStatus | getPosition (short &x_pos, short &y_pos) const
| Get the location of the event in view co-ordinates.
MStatus | setPosition (short x_pos, short y_pos)
| set the location of the event to the specified location.
MStatus | getWindowPosition (short &x_pos, short &y_pos) const
| This routine is used by responders to query the position of the pointer when the event occurred.
MouseButtonType | mouseButton (MStatus *ReturnStatus=NULL) const
| Get the mouse button of the last event.
bool | isModifierKeyRelease (MStatus *ReturnStatus=NULL) const
| Was a modifier key released.
ModifierType | modifiers (MStatus *ReturnStatus=NULL) const
| This routine is used by responders to find the state of the modifiers during the event.
MStatus | setModifiers (const ModifierType &modType)
| set the event modifiers.
bool | isModifierNone (MStatus *ReturnStatus=NULL) const
| Determines if there are any modifiers for this event.
bool | isModifierShift (MStatus *ReturnStatus=NULL) const
| return state of shift key.
bool | isModifierControl (MStatus *ReturnStatus=NULL) const
| return state of control key.
bool | isModifierLeftMouseButton (MStatus *ReturnStatus=NULL) const
| Return the state of the left mouse button.
bool | isModifierMiddleMouseButton (MStatus *ReturnStatus=NULL) const
| Return the state of the middle mouse button.
## Static Public Member Functions
static const char * | className ()
| Returns the name of this class.

## Member Enumeration Documentation

enum ModifierType

Search for all occurrences

Modifier key types.

Enumerator:

  shiftKey | Search for all occurrences
  controlKey | Search for all occurrences

enum MouseButtonType

Search for all occurrences

Mouse button types.

Enumerator:

  kLeftMouse | Search for all occurrences
  kMiddleMouse | Search for all occurrences

## Member Function Documentation

MStatus getPosition | ( | short & | x_pos,
|  | short & | y_pos
| ) |  | const

Search for all occurrences

Get the location of the event in view co-ordinates.

The origin is at the lower left corner of the window.

Parameters:

  [out] | x_pos | storage for horizonal position
  [out] | y_pos | storage for vertical position

Returns:
  Status Code

Status Codes:
  - MS::kSuccess The method was successful.
  - MS::kFailure Object error.

MStatus setPosition | ( | short | x_pos,
|  | short | y_pos
| ) |  |

Search for all occurrences

set the location of the event to the specified location.

The origin is at the lower left corner of the window.

Parameters:

  [in] | x_pos | horizonal position to set
  [in] | y_pos | vertical position to set

Returns:
  Status Code

Status Codes:
  - MS::kSuccess The method was successful.
  - MS::kFailure Object error.

MStatus getWindowPosition | ( | short & | x_pos,
|  | short & | y_pos
| ) |  | const

Search for all occurrences

This routine is used by responders to query the position of the pointer when the event occurred.

It is given in screen co-ordinates.

The origin is at the upper left corner of the window.

Parameters:

  [out] | x_pos | storage for horizonal position
  [out] | y_pos | storage for vertical position

Returns:
  Status Code

Status Codes:
  - MS::kSuccess The method was successful.
  - MS::kFailure Object error.

MEvent::MouseButtonType mouseButton | ( | MStatus * | ReturnStatus = `NULL` | ) | const

Search for all occurrences

Get the mouse button of the last event.

Parameters:

  [out] | ReturnStatus |

Returns:
  Mouse button from last event.

Status Codes:
  - MS::kSuccess The method was successful.
  - MS::kFailure Object error.

bool isModifierKeyRelease | ( | MStatus * | ReturnStatus = `NULL` | ) | const

Search for all occurrences

Was a modifier key released.

Parameters:

  [out] | ReturnStatus |

Returns:
  - true A modifier key was released.
  - false No modifier key was released.

Status Codes:
  - MS::kSuccess The method was successful.
  - MS::kFailure Object error.

MEvent::ModifierType modifiers | ( | MStatus * | ReturnStatus = `NULL` | ) | const

Search for all occurrences

This routine is used by responders to find the state of the modifiers during the event.

Parameters:

  [out] | ReturnStatus |

Returns:
  Modifier type.

Status Codes:
  - MS::kSuccess The method was successful.
  - MS::kFailure Object error.

MStatus setModifiers | ( | const ModifierType & | modType | ) |

Search for all occurrences

set the event modifiers.

Parameters:

  [in] | modType | Type of modifier to set to.

Returns:
  Status Code

Status Codes:
  - MS::kSuccess The method was successful.
  - MS::kFailure Object error.

bool isModifierNone | ( | MStatus * | ReturnStatus = `NULL` | ) | const

Search for all occurrences

Determines if there are any modifiers for this event.

Parameters:

  [out] | ReturnStatus |

Returns:
  - true There are modifiers for this event.
  - false There are NO modifiers for this event.

Status Codes:
  - MS::kSuccess The method was successful.
  - MS::kFailure Object error.

bool isModifierShift | ( | MStatus * | ReturnStatus = `NULL` | ) | const

Search for all occurrences

return state of shift key.

Parameters:

  [out] | ReturnStatus |

Returns:
  - true Shift key triggered this event.
  - false The shift key did not cause this event.

Status Codes:
  - MS::kSuccess The method was successful.
  - MS::kFailure Object error.

Examples:
  lassoTool.cpp, and marqueeTool.cpp.

bool isModifierControl | ( | MStatus * | ReturnStatus = `NULL` | ) | const

Search for all occurrences

return state of control key.

Parameters:

  [out] | ReturnStatus |

Returns:
  - true Control key triggered this event.
  - false The control key did not cause this event.

Status Codes:
  - MS::kSuccess The method was successful.
  - MS::kFailure Object error.

Examples:
  lassoTool.cpp, and marqueeTool.cpp.

bool isModifierLeftMouseButton | ( | MStatus * | ReturnStatus = `NULL` | ) | const

Search for all occurrences

Return the state of the left mouse button.

This method is only valid when called in the hold event for another mouse press.

Parameters:

  [out] | ReturnStatus |

Returns:
  - true Left mouse button triggered this event.
  - false The left moust button did not cause this event.

Status Codes:
  - MS::kSuccess The method was successful.
  - MS::kFailure Object error.

bool isModifierMiddleMouseButton | ( | MStatus * | ReturnStatus = `NULL` | ) | const

Search for all occurrences

Return the state of the middle mouse button.

This method is only valid when called in the hold event for another mouse press.

Parameters:

  [out] | ReturnStatus |

Returns:
  - true Middle mouse button triggered this event.
  - false The middle moust button did not cause this event.

Status Codes:
  - MS::kSuccess The method was successful.
  - MS::kFailure Object error.

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

Search for all occurrences

Returns the name of this class.

Returns:
  The name of this class.

MEvent MEvent MEvent MEvent MEvent MEvent MEvent MEvent MEvent MEvent
MEvent MEvent MEvent MEvent MEvent MEvent MEvent MEvent MEvent MEvent