Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# Ogre::MouseEvent Class Reference

An event which indicates that a mouse action occurred in a MouseTarget (e.g. More...

`#include <OgreMouseEvent.h>`

Inheritance diagram for Ogre::MouseEvent:

[legend]
List of all members.

## Public Types

enum | { ME_FIRST_EVENT = 500, ME_LAST_EVENT = 510 }
enum | { ME_MOUSE_CLICKED = ME_FIRST_EVENT, ME_MOUSE_PRESSED, ME_MOUSE_RELEASED, ME_MOUSE_MOVED, ME_MOUSE_ENTERED, ME_MOUSE_EXITED, ME_MOUSE_DRAGGED, ME_MOUSE_DRAGENTERED, ME_MOUSE_DRAGEXITED, ME_MOUSE_DRAGMOVED, ME_MOUSE_DRAGDROPPED }
enum | { SHIFT_MASK = 1 << 0, CTRL_MASK = 1 << 1, META_MASK = 1 << 2, ALT_MASK = 1 << 3, BUTTON0_MASK = 1 << 4, BUTTON1_MASK = 1 << 5, BUTTON2_MASK = 1 << 6, BUTTON3_MASK = 1 << 7, BUTTON_ANY_MASK = 0xF << 4 }

## Public Methods

| MouseEvent (PositionTarget *source, int id, int whichButton, Real when, int modifiers, Real x, Real y, Real z, int clickCount)
| Constructs a MouseEvent object with the specified source MouseTarget, type, modifiers, coordinates, and click count.
| MouseEvent (PositionTarget *source, int id, int whichButton, Real when, int modifiers, Real x, Real y, Real z, Real relx, Real rely, Real relz, int clickCount)
int | getClickCount ()
| Return the number of mouse clicks associated with this event.
Real | getX () const
| Returns the horizontal x position of the event relative to the source GuiElement.
Real | getY () const
| Returns the vertical y position of the event relative to the source GuiElement.
Real | getZ () const
| Returns the vertical y position of the event relative to the source GuiElement.
Real | getRelX () const
| get relative X cursor movement
Real | getRelY () const
| get relative Y cursor movement
Real | getRelZ () const
| get relative Z cursor movement
String | paramString () const
| Returns a parameter string identifying this event.
void | translatePoint (Real x, Real y)
| Translates the event's coordinates to a new position by adding specified x (horizontal) and y (veritcal) offsets.
int | getButtonID () const
| return the ID of the button
void | consume ()
| Consumes this event so that it will not be processed in the default manner by the source which originated it.
int | getModifiers () const
| Returns the modifiers flag for this event.
Real | getWhen () const
| Returns the timestamp of when this event occurred.
bool | isAltDown () const
| Returns whether or not the Alt modifier is down on this event.
bool | isConsumed () const
| Returns whether or not this event has been consumed.
bool | isControlDown () const
| Returns whether or not the Control modifier is down on this event.
bool | isMetaDown () const
| Returns whether or not the Meta modifier is down on this event.
bool | isShiftDown () const
| Returns whether or not the Shift modifier is down on this event.
bool | isEventBetween (int start, int end) const
int | getID () const
EventTarget * | getSource () const

## Protected Attributes

Real | mX
| The mouse events x coordinate.
Real | mY
| The mouse events y coordinate.
Real | mZ
| The mouse events z coordinate.
Real | mRelX
Real | mRelY
Real | mRelZ
int | mButtonID
| Which button was pressed.
int | mClickCount
| not implemented yet
Real | mWhen
| Not implemented yet.
int | mModifiers
| The state of the modifier keys at the time the input event was fired.
EventTarget * | mSource
| The target to process the event.
int | mId
| The ID of the event.
bool | mConsumed
| whether the event has been consumed

## Detailed Description

An event which indicates that a mouse action occurred in a MouseTarget (e.g.

MouseTarget).

Remarks:
  This event is used both for mouse events (click, enter, exit) and mouse motion events (moves and drags).

This low-level event is generated by a MouseTarget object for:

- Mouse Events
  - a mouse button is pressed
  - a mouse button is released
  - a mouse button is clicked (pressed and released)
  - the mouse cursor enters a MouseTarget
  - the mouse cursor exits a MouseTarget
- Mouse Motion Events
  - the mouse is moved
  - the mouse is dragged

A MouseEvent object is passed to every MouseListener object which registered to receive the "interesting" mouse events using MouseTarget's `addMouseListener` method.

A MouseEvent object is also passed to every MouseMotionListener object which registered to receive mouse motion events using the MouseTarget's addMouseMotionListener method

When a mouse button is clicked, events are generated and sent to the registered MouseListeners, with the button mask set in the modifier field. For example, if the first mouse button is pressed, events are sent in the following order:

        MOUSE_PRESSED:  BUTTON1_MASK
        MOUSE_RELEASED: BUTTON1_MASK
        MOUSE_CLICKED:  BUTTON1_MASK

When multiple mouse buttons are pressed, each press, release, and click results in a separate event. The button mask in the modifier field reflects only the button that changed state, not the current state of all buttons.

For example, if the user presses button 1 followed by button 2 and releases them in the same order, the following sequence of events is generated:

        MOUSE_PRESSED:  BUTTON1_MASK
        MOUSE_PRESSED:  BUTTON2_MASK
        MOUSE_RELEASED: BUTTON1_MASK
        MOUSE_CLICKED:  BUTTON1_MASK
        MOUSE_RELEASED: BUTTON2_MASK
        MOUSE_CLICKED:  BUTTON2_MASK

If button2 is released first, the MOUSE_RELEASED/MOUSE_CLICKED pair for BUTTON2_MASK arrives first, followed by the pair for BUTTON1_MASK.

Definition at line 158 of file OgreMouseEvent.h.

## Member Enumeration Documentation

anonymous enum

Enumeration values:

  ME_FIRST_EVENT |
  ME_LAST_EVENT |

Definition at line 201 of file OgreMouseEvent.h.

anonymous enum

Enumeration values:

  ME_MOUSE_CLICKED |
  ME_MOUSE_PRESSED |
  ME_MOUSE_RELEASED |
  ME_MOUSE_MOVED |
  ME_MOUSE_ENTERED |
  ME_MOUSE_EXITED |
  ME_MOUSE_DRAGGED |
  ME_MOUSE_DRAGENTERED |
  ME_MOUSE_DRAGEXITED |
  ME_MOUSE_DRAGMOVED |
  ME_MOUSE_DRAGDROPPED |

Definition at line 207 of file OgreMouseEvent.h.

anonymous enum`[inherited]`

Enumeration values:

  SHIFT_MASK | This flag indicates that the Shift key was down when the event occurred.
  CTRL_MASK | This flag indicates that the Control key was down when the event occurred.
  META_MASK | This flag indicates that the Meta key was down when the event occurred. For mouse events, this flag indicates that the right button was pressed or released.
  ALT_MASK | This flag indicates that the Alt key was down when the event occurred. For mouse events, this flag indicates that the middle mouse button was pressed or released.
  BUTTON0_MASK |
  BUTTON1_MASK |
  BUTTON2_MASK |
  BUTTON3_MASK |
  BUTTON_ANY_MASK |

Definition at line 93 of file OgreInputEvent.h.

## Constructor & Destructor Documentation

Ogre::MouseEvent::MouseEvent | ( | PositionTarget * | source,
|  | int | id,
|  | int | whichButton,
|  | Real | when,
|  | int | modifiers,
|  | Real | x,
|  | Real | y,
|  | Real | z,
|  | int | clickCount
| ) |

Constructs a MouseEvent object with the specified source MouseTarget, type, modifiers, coordinates, and click count.

Parameters:

  source | the MouseTarget that originated the event
  id | the integer that identifies the event
  when | a long int that gives the time the event occurred
  modifiers | the modifier keys down during event (shift, ctrl, alt, meta)
  x | the horizontal x coordinate for the mouse location
  y | the vertical y coordinate for the mouse location
  clickCount | the number of mouse clicks associated with event

Definition at line 34 of file OgreMouseEvent.cpp.

References Ogre::Real.

Ogre::MouseEvent::MouseEvent | ( | PositionTarget * | source,
|  | int | id,
|  | int | whichButton,
|  | Real | when,
|  | int | modifiers,
|  | Real | x,
|  | Real | y,
|  | Real | z,
|  | Real | relx,
|  | Real | rely,
|  | Real | relz,
|  | int | clickCount
| ) |

| Definition at line 44 of file OgreMouseEvent.cpp. References Ogre::Real.

## Member Function Documentation

void Ogre::InputEvent::consume | ( |  | ) | `[inherited]`

| Consumes this event so that it will not be processed in the default manner by the source which originated it. Definition at line 43 of file OgreInputEvent.cpp. References Ogre::InputEvent::mConsumed. Referenced by Ogre::EventDispatcher::retargetMouseEvent().

int Ogre::MouseEvent::getButtonID | ( |  | ) | const

| return the ID of the button Definition at line 97 of file OgreMouseEvent.cpp. References mButtonID. Referenced by Ogre::EventDispatcher::retargetMouseEvent().

int Ogre::MouseEvent::getClickCount | ( |  | ) |

Return the number of mouse clicks associated with this event.

Returns:
  integer value for the number of clicks - NOT IMPLEMENTED

Definition at line 62 of file OgreMouseEvent.cpp.

References mClickCount.

Referenced by Ogre::EventDispatcher::retargetMouseEvent().

int Ogre::InputEvent::getID | ( |  | ) | const`[inherited]`

Definition at line 89 of file OgreInputEvent.cpp.

References Ogre::InputEvent::mId.

Referenced by Ogre::ActionTarget::processActionEvent(), Ogre::TextBoxGuiElement::processEvent(), Ogre::ScrollBarGuiElement::processEvent(), Ogre::OverlayManager::processEvent(), Ogre::GuiElement::processEvent(), Ogre::GuiControl::processEvent(), Ogre::EventProcessor::processEvent(), Ogre::Cursor::processEvent(), Ogre::KeyTarget::processKeyEvent(), Ogre::MouseTarget::processMouseEvent(), Ogre::EventDispatcher::processMouseEvent(), Ogre::MouseMotionTarget::processMouseMotionEvent(), Ogre::ScrollTarget::processScrollEvent(), and Ogre::EventDispatcher::retargetMouseEvent().

int Ogre::InputEvent::getModifiers | ( |  | ) | const`[inherited]`

| Returns the modifiers flag for this event. Definition at line 48 of file OgreInputEvent.cpp. References Ogre::InputEvent::mModifiers. Referenced by paramString(), Ogre::EventDispatcher::retargetKeyEvent(), and Ogre::EventDispatcher::retargetMouseEvent().

Real Ogre::MouseEvent::getRelX | ( |  | ) | const

| get relative X cursor movement Definition at line 277 of file OgreMouseEvent.h. References Ogre::Real.

Real Ogre::MouseEvent::getRelY | ( |  | ) | const

| get relative Y cursor movement Definition at line 280 of file OgreMouseEvent.h. References Ogre::Real.

Real Ogre::MouseEvent::getRelZ | ( |  | ) | const

| get relative Z cursor movement Definition at line 283 of file OgreMouseEvent.h. References Ogre::Real.

EventTarget * Ogre::InputEvent::getSource | ( |  | ) | const`[inherited]`

| Definition at line 95 of file OgreInputEvent.cpp. References Ogre::InputEvent::mSource. Referenced by Ogre::ScrollBarGuiElement::mousePressed(), and Ogre::ListGuiElement::mousePressed().

Real Ogre::InputEvent::getWhen | ( |  | ) | const`[inherited]`

| Returns the timestamp of when this event occurred. Not implemented yet Definition at line 53 of file OgreInputEvent.cpp. References Ogre::InputEvent::mWhen, and Ogre::Real. Referenced by Ogre::EventDispatcher::retargetKeyEvent(), and Ogre::EventDispatcher::retargetMouseEvent().

Real Ogre::MouseEvent::getX | ( |  | ) | const

Returns the horizontal x position of the event relative to the source GuiElement.

Returns:
  x an integer indicating horizontal position relative to the MouseTarget

Definition at line 73 of file OgreMouseEvent.cpp.

References mX, and Ogre::Real.

Referenced by Ogre::ListGuiElement::mouseDragged(), Ogre::PopupMenuGuiElement::mouseMoved(), Ogre::CursorGuiElement::mouseMoved(), Ogre::EventDispatcher::processMouseEvent(), and Ogre::EventDispatcher::retargetMouseEvent().

Real Ogre::MouseEvent::getY | ( |  | ) | const

Returns the vertical y position of the event relative to the source GuiElement.

Returns:
  y an integer indicating vertical position relative to the MouseTarget

Definition at line 83 of file OgreMouseEvent.cpp.

References mY, and Ogre::Real.

Referenced by Ogre::ScrollBarGuiElement::mouseDragged(), Ogre::ListGuiElement::mouseDragged(), Ogre::PopupMenuGuiElement::mouseMoved(), Ogre::CursorGuiElement::mouseMoved(), Ogre::ScrollBarGuiElement::mousePressed(), Ogre::EventDispatcher::processMouseEvent(), and Ogre::EventDispatcher::retargetMouseEvent().

Real Ogre::MouseEvent::getZ | ( |  | ) | const

Returns the vertical y position of the event relative to the source GuiElement.

Returns:
  y an integer indicating scrollwheel position relative to the MouseTarget

Definition at line 94 of file OgreMouseEvent.cpp.

References mZ, and Ogre::Real.

Referenced by Ogre::EventDispatcher::retargetMouseEvent().

bool Ogre::InputEvent::isAltDown | ( |  | ) | const`[inherited]`

| Returns whether or not the Alt modifier is down on this event. Definition at line 58 of file OgreInputEvent.cpp. References Ogre::InputEvent::mModifiers.

bool Ogre::InputEvent::isConsumed | ( |  | ) | const`[inherited]`

Returns whether or not this event has been consumed.

See also:
  consume

Definition at line 63 of file OgreInputEvent.cpp.

References Ogre::InputEvent::mConsumed.

Referenced by Ogre::TextBoxGuiElement::processEvent(), Ogre::ScrollBarGuiElement::processEvent(), Ogre::GuiElement::processEvent(), Ogre::GuiControl::processEvent(), Ogre::EventProcessor::processEvent(), Ogre::EventDispatcher::processKeyEvent(), and Ogre::EventDispatcher::processMouseEvent().

bool Ogre::InputEvent::isControlDown | ( |  | ) | const`[inherited]`

| Returns whether or not the Control modifier is down on this event. Definition at line 68 of file OgreInputEvent.cpp. References Ogre::InputEvent::mModifiers.

bool Ogre::InputEvent::isEventBetween | ( | int | start,
|  | int | end
| ) | const`[inherited]`

| Definition at line 83 of file OgreInputEvent.cpp. References Ogre::InputEvent::mId. Referenced by Ogre::EventDispatcher::dispatchEvent().

bool Ogre::InputEvent::isMetaDown | ( |  | ) | const`[inherited]`

| Returns whether or not the Meta modifier is down on this event. Definition at line 73 of file OgreInputEvent.cpp. References Ogre::InputEvent::mModifiers.

bool Ogre::InputEvent::isShiftDown | ( |  | ) | const`[inherited]`

| Returns whether or not the Shift modifier is down on this event. Definition at line 78 of file OgreInputEvent.cpp. References Ogre::InputEvent::mModifiers.

String Ogre::MouseEvent::paramString | ( |  | ) | const

Returns a parameter string identifying this event.

This method is useful for event-logging and for debugging.

Returns:
  a string identifying the event and its attributes

Definition at line 109 of file OgreMouseEvent.cpp.

References Ogre::InputEvent::getModifiers(), mClickCount, ME_MOUSE_CLICKED, ME_MOUSE_DRAGDROPPED, ME_MOUSE_DRAGENTERED, ME_MOUSE_DRAGEXITED, ME_MOUSE_DRAGGED, ME_MOUSE_DRAGMOVED, ME_MOUSE_ENTERED, ME_MOUSE_EXITED, ME_MOUSE_MOVED, ME_MOUSE_PRESSED, ME_MOUSE_RELEASED, mX, mY, and Ogre::String.

void Ogre::MouseEvent::translatePoint | ( | Real | x,
|  | Real | y
| ) |

Translates the event's coordinates to a new position by adding specified x (horizontal) and y (veritcal) offsets.

Parameters:

  x | the horizontal x value to add to the current x coordinate position
  y | the vertical y value to add to the current y coordinate position

Definition at line 159 of file OgreMouseEvent.cpp.

References mX, mY, and Ogre::Real.

## Member Data Documentation

int Ogre::MouseEvent::mButtonID`[protected]`

| Which button was pressed. Definition at line 190 of file OgreMouseEvent.h. Referenced by getButtonID().

int Ogre::MouseEvent::mClickCount`[protected]`

| not implemented yet Definition at line 194 of file OgreMouseEvent.h. Referenced by getClickCount(), and paramString().

bool Ogre::InputEvent::mConsumed`[protected, inherited]`

| whether the event has been consumed Definition at line 88 of file OgreInputEvent.h. Referenced by Ogre::InputEvent::consume(), Ogre::InputEvent::InputEvent(), and Ogre::InputEvent::isConsumed().

int Ogre::InputEvent::mId`[protected, inherited]`

| The ID of the event. Definition at line 83 of file OgreInputEvent.h. Referenced by Ogre::InputEvent::getID(), and Ogre::InputEvent::isEventBetween().

int Ogre::InputEvent::mModifiers`[protected, inherited]`

| The state of the modifier keys at the time the input event was fired. Definition at line 72 of file OgreInputEvent.h. Referenced by Ogre::KeyEvent::getKeyChar(), Ogre::InputEvent::getModifiers(), Ogre::InputEvent::isAltDown(), Ogre::InputEvent::isControlDown(), Ogre::InputEvent::isMetaDown(), and Ogre::InputEvent::isShiftDown().

Real Ogre::MouseEvent::mRelX`[protected]`

| Definition at line 182 of file OgreMouseEvent.h.

Real Ogre::MouseEvent::mRelY`[protected]`

| Definition at line 183 of file OgreMouseEvent.h.

Real Ogre::MouseEvent::mRelZ`[protected]`

| Definition at line 184 of file OgreMouseEvent.h.

EventTarget* Ogre::InputEvent::mSource`[protected, inherited]`

| The target to process the event. This is ususally found by the dispatcher Definition at line 78 of file OgreInputEvent.h. Referenced by Ogre::InputEvent::getSource().

Real Ogre::InputEvent::mWhen`[protected, inherited]`

| Not implemented yet. Definition at line 67 of file OgreInputEvent.h. Referenced by Ogre::InputEvent::getWhen().

Real Ogre::MouseEvent::mX`[protected]`

| The mouse events x coordinate. The x value is relative to the MouseTarget that fired the event. Definition at line 166 of file OgreMouseEvent.h. Referenced by getX(), paramString(), and translatePoint().

Real Ogre::MouseEvent::mY`[protected]`

| The mouse events y coordinate. The y value is relative to the MouseTarget that fired the event. Definition at line 172 of file OgreMouseEvent.h. Referenced by getY(), paramString(), and translatePoint().

Real Ogre::MouseEvent::mZ`[protected]`

| The mouse events z coordinate. The z value is relative to the MouseTarget that fired the event. Definition at line 179 of file OgreMouseEvent.h. Referenced by getZ().

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

- OgreMouseEvent.h
- OgreMouseEvent.cpp

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:51:15 2004