Castor3D 0.16.0
Multiplatform 3D engine
Public Types | List of all members
castor3d::UserInputListener Class Referenceabstract

#include <UserInputListener.hpp>

Inheritance diagram for castor3d::UserInputListener:
Inheritance graph
[legend]
Collaboration diagram for castor3d::UserInputListener:
Collaboration graph
[legend]

Public Types

using OnClickActionFunction = castor::Function< void() >
 
using OnMouseMoveActionFunction = castor::Function< void( castor::Position const & ) >
 
using OnSelectActionFunction = castor::Function< void( int ) >
 
using OnTextActionFunction = castor::Function< void( castor::U32String const & ) >
 
using OnExpandActionFunction = castor::Function< void( bool ) >
 
using OnClipboardTextActionFunction = castor::Function< castor::U32String( bool, castor::U32String ) >
 
using OnCursorActionFunction = castor::Function< void( MouseCursor ) >
 

Public Member Functions

General
 UserInputListener (UserInputListener const &)=delete
 
 UserInputListener (UserInputListener &&) noexcept=delete
 
UserInputListeneroperator= (UserInputListener const &)=delete
 
UserInputListeneroperator= (UserInputListener &&) noexcept=delete
 
C3D_API UserInputListener (Engine &engine, castor::String const &name)
 Constructor.
 
virtual C3D_API ~UserInputListener () noexcept=default
 Destructor.
 
C3D_API bool initialise ()
 Initialises the listener.
 
C3D_API void cleanup ()
 Cleans up the listener.
 
C3D_API void processEvents ()
 Processes all queued events.
 
Getters
castor::Position const & getMousePosition () const
 
EventHandlerRPtr getActiveControl () const
 
EventHandlerRPtr getFocusedControl () const
 
FrameListenergetFrameListener () const
 
Output events
C3D_API void registerMouseMoveAction (castor::String const &handler, OnMouseMoveActionFunction function)
 Registers a function to call when a mouse move event is raised by the given handler.
 
C3D_API void registerClickAction (castor::String const &handler, OnClickActionFunction function)
 Registers a function to call when a mouse click event is raised by the given handler.
 
C3D_API void registerSelectAction (castor::String const &handler, OnSelectActionFunction function)
 Registers a function to call when a select event is raised by the given handler.
 
C3D_API void registerTextAction (castor::String const &handler, OnTextActionFunction function)
 Registers a function to call when a text event is raised by the given handler.
 
C3D_API void registerExpandAction (castor::String const &handler, OnExpandActionFunction function)
 Registers a function to call when an expand event is raised by the given handler.
 
C3D_API void registerCursorAction (OnCursorActionFunction function)
 Registers a function to call when a mouse cursor event is raised by the given handler.
 
C3D_API void registerClipboardTextAction (OnClipboardTextActionFunction function)
 Registers a function to call when a clipboard event is raised by the given handler.
 
C3D_API void unregisterMouseMoveAction (castor::String const &handler)
 Unregisters ths function to call when a mouse move event is raised by the given handler.
 
C3D_API void unregisterClickAction (castor::String const &handler)
 Unregisters ths function to call when a mouse click event is raised by the given handler.
 
C3D_API void unregisterSelectAction (castor::String const &handler)
 Unregisters ths function to call when a select event is raised by the given handler.
 
C3D_API void unregisterTextAction (castor::String const &handler)
 Unregisters ths function to call when a text event is raised by the given handler.
 
C3D_API void unregisterExpandAction (castor::String const &handler)
 Unregisters ths function to call when an expand event is raised by the given handler.
 
C3D_API void unregisterCursorAction ()
 Unregisters the function to call when mouse cursor event is raised by the given handler.
 
C3D_API void unregisterClipboardTextAction ()
 Unregisters the function to call when a clipboard event is raised by the given handler.
 
C3D_API void onMouseMoveAction (castor::String const &handler) const
 Event raised by the handler when the mouse is moved over it.
 
C3D_API void onClickAction (castor::String const &handler) const
 Event raised by the handler when it is clicked, if it supports clicking.
 
C3D_API void onSelectAction (castor::String const &handler, int index) const
 Event raised by the handler when one of its sub elements is selected.
 
C3D_API void onTextAction (castor::String const &handler, castor::U32String const &text) const
 Event raised by the handler when its caption has changed.
 
C3D_API void onExpandAction (castor::String const &handler, bool expand) const
 Event raised by the handler when its expansion has changed.
 
C3D_API void onCursorAction (MouseCursor cursor) const
 Event raised when mouse cursor has changed.
 
C3D_API castor::U32String onClipboardTextAction (bool set, castor::U32String text) const
 Event raised interaction with the clipboard is needed.
 
C3D_API void enableHandler (castor::String const &handler)
 Enables handler.
 
C3D_API void disableHandler (castor::String const &handler)
 Disables handler.
 
Mouse input events
C3D_API bool fireMouseMove (castor::Position const &position, bool ctrl, bool alt, bool shift)
 Fires a mouse move event.
 
C3D_API bool fireMouseButtonPushed (MouseButton button, bool ctrl, bool alt, bool shift)
 Fires a mouse pushed event.
 
C3D_API bool fireMouseButtonReleased (MouseButton button, bool ctrl, bool alt, bool shift)
 Fires a mouse released event.
 
C3D_API bool fireMouseWheel (castor::Position const &offsets, bool ctrl, bool alt, bool shift)
 Fires a mouse wheel event.
 
- Public Member Functions inherited from castor::OwnedBy< Engine >
Engine * getOwner () const
 

Keyboard input events

castor::Mutex m_mutexHandlers
 
castor::Vector< EventHandlerUPtr > m_handlers
 
FrameListenerRPtr m_frameListener
 
C3D_API bool fireKeydown (KeyboardKey key, bool ctrl, bool alt, bool shift)
 Fires a keyboard key down event.
 
C3D_API bool fireKeyUp (KeyboardKey key, bool ctrl, bool alt, bool shift)
 Fires a keyboard key up event.
 
C3D_API bool fireChar (KeyboardKey key, castor::String const &c)
 Fires a printable key event.
 
castor::Vector< EventHandlerRPtr > doGetHandlers () const
 
bool doHasHandlers () const
 
EventHandlerRPtr doAddHandler (EventHandlerUPtr handler)
 Removes a handler.
 
void doRemoveHandlerNL (EventHandler const &handler)
 Removes a handler.
 
void doRemoveHandler (EventHandler const &handler)
 Removes a handler.
 

Additional Inherited Members

- Protected Member Functions inherited from castor::OwnedBy< Engine >
 OwnedBy (Engine &owner)
 Constructor.
 

Member Typedef Documentation

◆ OnClickActionFunction

◆ OnClipboardTextActionFunction

◆ OnCursorActionFunction

◆ OnExpandActionFunction

◆ OnMouseMoveActionFunction

◆ OnSelectActionFunction

◆ OnTextActionFunction

Constructor & Destructor Documentation

◆ UserInputListener() [1/3]

castor3d::UserInputListener::UserInputListener ( UserInputListener const & )
delete

◆ UserInputListener() [2/3]

castor3d::UserInputListener::UserInputListener ( UserInputListener && )
deletenoexcept

◆ UserInputListener() [3/3]

C3D_API castor3d::UserInputListener::UserInputListener ( Engine & engine,
castor::String const & name )

Constructor.

Parameters
[in]engineThe engine.
[in]nameThe listener's name.

◆ ~UserInputListener()

virtual C3D_API castor3d::UserInputListener::~UserInputListener ( )
virtualdefaultnoexcept

Destructor.

Member Function Documentation

◆ cleanup()

C3D_API void castor3d::UserInputListener::cleanup ( )

Cleans up the listener.

◆ disableHandler()

C3D_API void castor3d::UserInputListener::disableHandler ( castor::String const & handler)

Disables handler.

Parameters
[in]handlerThe handler.

◆ doAddHandler()

EventHandlerRPtr castor3d::UserInputListener::doAddHandler ( EventHandlerUPtr handler)
inlineprotected

Removes a handler.

Remarks
You MUST call this function when adding a handler to your lists, if you want to have it updated.
Parameters
[in]handlerThe handler.

References CU_Exception, m_handlers, m_mutexHandlers, and castor::makeUniqueLock().

Here is the call graph for this function:

◆ doGetHandlers()

castor::Vector< EventHandlerRPtr > castor3d::UserInputListener::doGetHandlers ( ) const
inlineprotected
Returns
The handlers, in a thread-safe way.

References m_handlers, m_mutexHandlers, and castor::makeUniqueLock().

Here is the call graph for this function:

◆ doHasHandlers()

bool castor3d::UserInputListener::doHasHandlers ( ) const
inlineprotected
Returns
true if there are handlers.

References m_handlers, m_mutexHandlers, and castor::makeUniqueLock().

Here is the call graph for this function:

◆ doRemoveHandler()

void castor3d::UserInputListener::doRemoveHandler ( EventHandler const & handler)
inlineprotected

Removes a handler.

Parameters
[in]handlerThe handler.

References doRemoveHandlerNL(), m_mutexHandlers, and castor::makeUniqueLock().

Here is the call graph for this function:

◆ doRemoveHandlerNL()

void castor3d::UserInputListener::doRemoveHandlerNL ( EventHandler const & handler)
inlineprotected

Removes a handler.

Parameters
[in]handlerThe handler.

References m_handlers.

Referenced by doRemoveHandler().

Here is the caller graph for this function:

◆ enableHandler()

C3D_API void castor3d::UserInputListener::enableHandler ( castor::String const & handler)

Enables handler.

Parameters
[in]handlerThe handler.

◆ fireChar()

C3D_API bool castor3d::UserInputListener::fireChar ( KeyboardKey key,
castor::String const & c )

Fires a printable key event.

Parameters
[in]keyThe key code.
[in]cThe character coorresponding to the key, displayable as is.
Returns
true if the event is processed by a control.

◆ fireKeydown()

C3D_API bool castor3d::UserInputListener::fireKeydown ( KeyboardKey key,
bool ctrl,
bool alt,
bool shift )

Fires a keyboard key down event.

Parameters
[in]keyThe key code.
[in]ctrlTells if the Ctrl key is down.
[in]altTells if the Alt key is down.
[in]shiftTells if the Shift key is down.
Returns
true if the event is processed by a handler.

◆ fireKeyUp()

C3D_API bool castor3d::UserInputListener::fireKeyUp ( KeyboardKey key,
bool ctrl,
bool alt,
bool shift )

Fires a keyboard key up event.

Parameters
[in]keyThe key code.
[in]ctrlTells if the Ctrl key is down.
[in]altTells if the Alt key is down.
[in]shiftTells if the Shift key is down.
Returns
true if the event is processed by a control.

◆ fireMouseButtonPushed()

C3D_API bool castor3d::UserInputListener::fireMouseButtonPushed ( MouseButton button,
bool ctrl,
bool alt,
bool shift )

Fires a mouse pushed event.

Parameters
[in]buttonThe mouse button.
[in]ctrlTells if the Ctrl key is down.
[in]altTells if the Alt key is down.
[in]shiftTells if the Shift key is down.
Returns
true if the event is processed by a handler.

◆ fireMouseButtonReleased()

C3D_API bool castor3d::UserInputListener::fireMouseButtonReleased ( MouseButton button,
bool ctrl,
bool alt,
bool shift )

Fires a mouse released event.

Parameters
[in]buttonThe mouse button.
[in]ctrlTells if the Ctrl key is down.
[in]altTells if the Alt key is down.
[in]shiftTells if the Shift key is down.
Returns
true if the event is processed by a handler.

◆ fireMouseMove()

C3D_API bool castor3d::UserInputListener::fireMouseMove ( castor::Position const & position,
bool ctrl,
bool alt,
bool shift )

Fires a mouse move event.

Parameters
[in]positionThe mouse position.
[in]ctrlTells if the Ctrl key is down.
[in]altTells if the Alt key is down.
[in]shiftTells if the Shift key is down.
Returns
true if the event is processed by a handler.

◆ fireMouseWheel()

C3D_API bool castor3d::UserInputListener::fireMouseWheel ( castor::Position const & offsets,
bool ctrl,
bool alt,
bool shift )

Fires a mouse wheel event.

Parameters
[in]offsetsThe mouse wheel offsets (x and y).
[in]ctrlTells if the Ctrl key is down.
[in]altTells if the Alt key is down.
[in]shiftTells if the Shift key is down.
Returns
true if the event is processed by a handler.

◆ getActiveControl()

EventHandlerRPtr castor3d::UserInputListener::getActiveControl ( ) const
inline

◆ getFocusedControl()

EventHandlerRPtr castor3d::UserInputListener::getFocusedControl ( ) const
inline

◆ getFrameListener()

FrameListener & castor3d::UserInputListener::getFrameListener ( ) const
inline

References m_frameListener.

◆ getMousePosition()

castor::Position const & castor3d::UserInputListener::getMousePosition ( ) const
inline

◆ initialise()

C3D_API bool castor3d::UserInputListener::initialise ( )

Initialises the listener.

Returns
true, hopefully :P.

◆ onClickAction()

C3D_API void castor3d::UserInputListener::onClickAction ( castor::String const & handler) const

Event raised by the handler when it is clicked, if it supports clicking.

Parameters
[in]handlerThe clicked handler.

◆ onClipboardTextAction()

C3D_API castor::U32String castor3d::UserInputListener::onClipboardTextAction ( bool set,
castor::U32String text ) const

Event raised interaction with the clipboard is needed.

Parameters
[in]settrue to define the clipboard text, false to retrieve it.
[in]textThe value to set the clipboard text to.
Returns
The clipboard text.

◆ onCursorAction()

C3D_API void castor3d::UserInputListener::onCursorAction ( MouseCursor cursor) const

Event raised when mouse cursor has changed.

Parameters
[in]cursorThe cursor.

◆ onExpandAction()

C3D_API void castor3d::UserInputListener::onExpandAction ( castor::String const & handler,
bool expand ) const

Event raised by the handler when its expansion has changed.

Parameters
[in]handlerThe handler.
[in]expandThe new value.

◆ onMouseMoveAction()

C3D_API void castor3d::UserInputListener::onMouseMoveAction ( castor::String const & handler) const

Event raised by the handler when the mouse is moved over it.

Parameters
[in]handlerThe handler.

◆ onSelectAction()

C3D_API void castor3d::UserInputListener::onSelectAction ( castor::String const & handler,
int index ) const

Event raised by the handler when one of its sub elements is selected.

Parameters
[in]handlerThe handler.
[in]indexThe selection index.

◆ onTextAction()

C3D_API void castor3d::UserInputListener::onTextAction ( castor::String const & handler,
castor::U32String const & text ) const

Event raised by the handler when its caption has changed.

Parameters
[in]handlerThe handler.
[in]textThe new text.

◆ operator=() [1/2]

UserInputListener & castor3d::UserInputListener::operator= ( UserInputListener && )
deletenoexcept

◆ operator=() [2/2]

UserInputListener & castor3d::UserInputListener::operator= ( UserInputListener const & )
delete

◆ processEvents()

C3D_API void castor3d::UserInputListener::processEvents ( )

Processes all queued events.

◆ registerClickAction()

C3D_API void castor3d::UserInputListener::registerClickAction ( castor::String const & handler,
OnClickActionFunction function )

Registers a function to call when a mouse click event is raised by the given handler.

Parameters
[in]handlerThe clicked handler.
[in]functionThe function.

◆ registerClipboardTextAction()

C3D_API void castor3d::UserInputListener::registerClipboardTextAction ( OnClipboardTextActionFunction function)

Registers a function to call when a clipboard event is raised by the given handler.

Parameters
[in]functionThe function.

◆ registerCursorAction()

C3D_API void castor3d::UserInputListener::registerCursorAction ( OnCursorActionFunction function)

Registers a function to call when a mouse cursor event is raised by the given handler.

Parameters
[in]functionThe function.

◆ registerExpandAction()

C3D_API void castor3d::UserInputListener::registerExpandAction ( castor::String const & handler,
OnExpandActionFunction function )

Registers a function to call when an expand event is raised by the given handler.

Parameters
[in]handlerThe handler.
[in]functionThe function.

◆ registerMouseMoveAction()

C3D_API void castor3d::UserInputListener::registerMouseMoveAction ( castor::String const & handler,
OnMouseMoveActionFunction function )

Registers a function to call when a mouse move event is raised by the given handler.

Parameters
[in]handlerThe handler.
[in]functionThe function.

◆ registerSelectAction()

C3D_API void castor3d::UserInputListener::registerSelectAction ( castor::String const & handler,
OnSelectActionFunction function )

Registers a function to call when a select event is raised by the given handler.

Parameters
[in]handlerThe handler.
[in]functionThe function.

◆ registerTextAction()

C3D_API void castor3d::UserInputListener::registerTextAction ( castor::String const & handler,
OnTextActionFunction function )

Registers a function to call when a text event is raised by the given handler.

Parameters
[in]handlerThe handler.
[in]functionThe function.

◆ unregisterClickAction()

C3D_API void castor3d::UserInputListener::unregisterClickAction ( castor::String const & handler)

Unregisters ths function to call when a mouse click event is raised by the given handler.

Parameters
[in]handlerThe clicked handler.

◆ unregisterClipboardTextAction()

C3D_API void castor3d::UserInputListener::unregisterClipboardTextAction ( )

Unregisters the function to call when a clipboard event is raised by the given handler.

◆ unregisterCursorAction()

C3D_API void castor3d::UserInputListener::unregisterCursorAction ( )

Unregisters the function to call when mouse cursor event is raised by the given handler.

◆ unregisterExpandAction()

C3D_API void castor3d::UserInputListener::unregisterExpandAction ( castor::String const & handler)

Unregisters ths function to call when an expand event is raised by the given handler.

Parameters
[in]handlerThe handler.

◆ unregisterMouseMoveAction()

C3D_API void castor3d::UserInputListener::unregisterMouseMoveAction ( castor::String const & handler)

Unregisters ths function to call when a mouse move event is raised by the given handler.

Parameters
[in]handlerThe handler.

◆ unregisterSelectAction()

C3D_API void castor3d::UserInputListener::unregisterSelectAction ( castor::String const & handler)

Unregisters ths function to call when a select event is raised by the given handler.

Parameters
[in]handlerThe handler.

◆ unregisterTextAction()

C3D_API void castor3d::UserInputListener::unregisterTextAction ( castor::String const & handler)

Unregisters ths function to call when a text event is raised by the given handler.

Parameters
[in]handlerThe handler.

Member Data Documentation

◆ m_frameListener

FrameListenerRPtr castor3d::UserInputListener::m_frameListener
protected

The associated frame listener.

Referenced by getFrameListener().

◆ m_handlers

castor::Vector< EventHandlerUPtr > castor3d::UserInputListener::m_handlers
protected

The handlers array.

Referenced by doAddHandler(), doGetHandlers(), doHasHandlers(), and doRemoveHandlerNL().

◆ m_mutexHandlers

castor::Mutex castor3d::UserInputListener::m_mutexHandlers
mutableprotected

The mutex used to protect the handlers array.

Referenced by doAddHandler(), doGetHandlers(), doHasHandlers(), and doRemoveHandler().


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