OpendTect  6.6
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
MouseEventHandler Class Reference
Inheritance diagram for MouseEventHandler:
[legend]

Public Member Functions

 MouseEventHandler ()
 
 ~MouseEventHandler ()
 
const MouseEventevent () const
 
bool hasEvent () const
 
bool isHandled () const
 
void setHandled (bool yn)
 
void triggerButtonPressed (const MouseEvent &)
 
void triggerButtonReleased (const MouseEvent &)
 
void triggerDoubleClick (const MouseEvent &)
 
void triggerMovement (const MouseEvent &)
 
void triggerWheel (const MouseEvent &)
 
- Public Member Functions inherited from CallBacker
 CallBacker ()
 
 CallBacker (const CallBacker &)
 
virtual ~CallBacker ()
 
bool attachCB (const NotifierAccess &, const CallBack &, bool onlyifnew=false) const
 
bool attachCB (const NotifierAccess *notif, const CallBack &cb, bool onlyifnew=false) const
 
void detachAllNotifiers () const
 Call from the destructor of your inherited object. More...
 
void detachCB (const NotifierAccess &, const CallBack &) const
 
void detachCB (const NotifierAccess *notif, const CallBack &cb) const
 
virtual bool isCapsule () const
 
bool isNotifierAttached (const NotifierAccess *) const
 Only for debugging purposes, don't use. More...
 
void stopReceivingNotifications () const
 

Public Attributes

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

Protected Member Functions

void setEvent (const MouseEvent *)
 

Protected Attributes

MouseEventevent_
 
bool ishandled_
 

Additional Inherited Members

- Static Public Member Functions inherited from CallBacker
static void createReceiverForCurrentThread ()
 
static void removeReceiverForCurrentThread ()
 

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();
{
eventhandler_->setHandled( true );
//show and handle menu
}
}
Inherit from this class to be able to send and/or receive CallBacks.
Definition: callback.h:185
const MouseEvent & event() const
Definition: mouseevent.h:207
Definition: mouseevent.h:73
bool ctrlStatus() const
bool shiftStatus() const
bool altStatus() const
bool rightButton() const
bool leftButton() const
bool middleButton() const

<>

Constructor & Destructor Documentation

◆ MouseEventHandler()

MouseEventHandler::MouseEventHandler ( )

◆ ~MouseEventHandler()

MouseEventHandler::~MouseEventHandler ( )

Member Function Documentation

◆ event()

const MouseEvent& MouseEventHandler::event ( ) const
inline
Note
only call in function triggered by an event from this class.

◆ hasEvent()

bool MouseEventHandler::hasEvent ( ) const
inline

◆ isHandled()

bool MouseEventHandler::isHandled ( ) const
inline

◆ setEvent()

void MouseEventHandler::setEvent ( const MouseEvent )
protected

◆ setHandled()

void MouseEventHandler::setHandled ( bool  yn)
inline

◆ triggerButtonPressed()

void MouseEventHandler::triggerButtonPressed ( const MouseEvent )

◆ triggerButtonReleased()

void MouseEventHandler::triggerButtonReleased ( const MouseEvent )

◆ triggerDoubleClick()

void MouseEventHandler::triggerDoubleClick ( const MouseEvent )

◆ triggerMovement()

void MouseEventHandler::triggerMovement ( const MouseEvent )

◆ triggerWheel()

void MouseEventHandler::triggerWheel ( const MouseEvent )

Member Data Documentation

◆ buttonPressed

Notifier<MouseEventHandler> MouseEventHandler::buttonPressed

◆ buttonReleased

Notifier<MouseEventHandler> MouseEventHandler::buttonReleased

◆ doubleClick

Notifier<MouseEventHandler> MouseEventHandler::doubleClick

◆ event_

MouseEvent* MouseEventHandler::event_
protected

◆ ishandled_

bool MouseEventHandler::ishandled_
protected

◆ movement

Notifier<MouseEventHandler> MouseEventHandler::movement

◆ wheelMove

Notifier<MouseEventHandler> MouseEventHandler::wheelMove

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2022