Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes

MouseEventHandler Class Reference

Inheritance diagram for MouseEventHandler:
CallBacker

List of all members.

Public Member Functions

 MouseEventHandler ()
 ~MouseEventHandler ()
void triggerMovement (const MouseEvent &)
void triggerButtonPressed (const MouseEvent &)
void triggerButtonReleased (const MouseEvent &)
void triggerDoubleClick (const MouseEvent &)
void triggerWheel (const MouseEvent &)
bool hasEvent () const
const MouseEventevent () const
bool isHandled () const
void setHandled (bool yn)

Public Attributes

Notifier< MouseEventHandlerbuttonPressed
Notifier< MouseEventHandlerbuttonReleased
Notifier< MouseEventHandlermovement
Notifier< MouseEventHandlerdoubleClick
Notifier< MouseEventHandlerwheelMove

Protected Member Functions

void setEvent (const MouseEvent *)

Protected Attributes

MouseEventevent_
bool ishandled_
bool tabletispressed_
OD::ButtonState curtabletbutstate_
bool tabletinsyncwithmouse_

Detailed Description

Handles mouse events. An instance of the MouseEventHandler is provided by the object that detects the mouse-click, e.g. a gui or visualization object.

Once the event callback is recieved, it MUST check if someone else have handled the event and taken necessary actions. If it is not already handled, and your class handles it, it should set the isHandled flag to prevent other objects in the callback chain to handle the event. It is often a good idea to be very specific what events your function should handle to avoid interference with other objects that are in the callback chain. As an example, see the code below: The if-statement will only let right-clicks when no other mouse or keyboard button are pressed through.

void MyClass::handleMouseClick( CallBacker* cb )
{
    if ( eventhandler_->isHandled() )
        return;

    const MouseEvent& event = eventhandler_->event();
    if ( event.rightButton() && !event.leftButton() && !event.middleButton() &&
         !event.ctrlStatus() && !event.altStatus() && !event.shiftStatus() )
    {
        eventhandler_->setHandled( true );
        //show and handle menu
    }
}

Constructor & Destructor Documentation

MouseEventHandler::MouseEventHandler (  ) 
MouseEventHandler::~MouseEventHandler (  ) 

Member Function Documentation

const MouseEvent& MouseEventHandler::event (  )  const [inline]
Note:
only call in function triggered by an event from this class.
bool MouseEventHandler::hasEvent (  )  const [inline]
bool MouseEventHandler::isHandled (  )  const [inline]
void MouseEventHandler::setEvent ( const MouseEvent  )  [protected]
void MouseEventHandler::setHandled ( bool  yn  )  [inline]
void MouseEventHandler::triggerButtonPressed ( const MouseEvent  ) 
void MouseEventHandler::triggerButtonReleased ( const MouseEvent  ) 
void MouseEventHandler::triggerDoubleClick ( const MouseEvent  ) 
void MouseEventHandler::triggerMovement ( const MouseEvent  ) 
void MouseEventHandler::triggerWheel ( const MouseEvent  ) 

Member Data Documentation

OD::ButtonState MouseEventHandler::curtabletbutstate_ [protected]