|
CarnegieMellonGraphics | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
MouseEvents are generated whenever the user performs some action with the mouse. The types of MouseEvents that can occur are listed below as part of the MouseEvent::Event enumeration.
MouseEvents are designed to work in a manner so that a user can easily "match" and filter out events in which they have interest. Basically the user constructs a new event to match against the event they currently have. The MouseEvent constructor has several default parameters so the user doesn't need to specify more detail about the event than they need.
It is also possible to simply obtain pertinent information about an event through the accessor member functions.
For example, if the user has just removed a mouse event from the mouse input queue, and they want to see if the mouse was clicked they can do the following:
if(MouseEvent(MouseEvent::BUTTON_CLICK_EVENT) == an_event) // do something
Or a more complicated example would be if the user wanted to check to see if the mouse has was moved over position (x, y) while holding down the left button they would do this:
if(MouseEvent(MouseEvent::MOUSE_MOVE_EVENT, MouseEvent::LEFT_BUTTON, x, y) == an_event) // do something else
Finally, if you wanted to check to see if the right mouse buton has been pressed down while holding down the shift key, you would do the following:
if(MouseEvent(MouseEvent::ButtonDown, MouseEvent::RIGHT_BUTTON, -1, -1, KeyModifiers::SHIFT) == an_event) // do more of something else
In this case the coordinate of (-1, -1) indicates the location at which the button press occurred does not matter.
Note that on some platforms, certain mouse and modifier combinations will be trapped by the operating system/window manager and will not be reported as having taken place.
Inner Classes, Typedefs, and Enums | |
typedef |
MouseEvent::Button
These are the buttons that CMG recognizes. |
typedef |
MouseEvent::Event
These are the events that CMG reports. |
Constructor Summary | |
MouseEvent( const MouseEvent::Event e, const MouseEvent::Button b = ANY_BUTTON, const int x =-1, const int y =-1, const KeyModifiers km = KeyModifiers::ANY_MODIFIERS )
Constructor for a mouse event from a set of parameters. |
|
MouseEvent( const MouseEvent& me )
Copy constructor |
|
MouseEvent()
Default constructor |
Method Summary | |
const MouseEvent::Button |
getButton() const
|
const MouseEvent::Event |
getEvent() const
|
const KeyModifiers |
getModifiers() const
|
const int |
getX() const
|
const int |
getY() const
|
bool |
operator!=( const MouseEvent& rhs ) const
Comparison operator for inequality on events. |
bool |
operator==( const MouseEvent& rhs ) const
Comparison operator for equality on events. |
Constructor Detail |
public MouseEvent( const MouseEvent::Event e, const MouseEvent::Button b = ANY_BUTTON, const int x =-1, const int y =-1, const KeyModifiers km = KeyModifiers::ANY_MODIFIERS );
public MouseEvent( const MouseEvent& me );
public MouseEvent();
Method Detail |
public const MouseEvent::Button getButton() const;
public const MouseEvent::Event getEvent() const;
public const KeyModifiers getModifiers() const;
public const int getX() const;
public const int getY() const;
public bool operator!=( const MouseEvent& rhs ) const;
public bool operator==( const MouseEvent& rhs ) const;
|
CarnegieMellonGraphics | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |