Castor3D 0.16.0
Multiplatform 3D engine
|
#include <UserInputListener.hpp>
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 | |
UserInputListener & | operator= (UserInputListener const &)=delete |
UserInputListener & | operator= (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 |
FrameListener & | getFrameListener () 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. | |
using castor3d::UserInputListener::OnClickActionFunction = castor::Function< void() > |
using castor3d::UserInputListener::OnClipboardTextActionFunction = castor::Function< castor::U32String( bool, castor::U32String ) > |
using castor3d::UserInputListener::OnCursorActionFunction = castor::Function< void( MouseCursor ) > |
using castor3d::UserInputListener::OnExpandActionFunction = castor::Function< void( bool ) > |
using castor3d::UserInputListener::OnMouseMoveActionFunction = castor::Function< void( castor::Position const & ) > |
using castor3d::UserInputListener::OnSelectActionFunction = castor::Function< void( int ) > |
using castor3d::UserInputListener::OnTextActionFunction = castor::Function< void( castor::U32String const & ) > |
|
delete |
|
deletenoexcept |
C3D_API castor3d::UserInputListener::UserInputListener | ( | Engine & | engine, |
castor::String const & | name ) |
Constructor.
[in] | engine | The engine. |
[in] | name | The listener's name. |
|
virtualdefaultnoexcept |
Destructor.
C3D_API void castor3d::UserInputListener::cleanup | ( | ) |
Cleans up the listener.
C3D_API void castor3d::UserInputListener::disableHandler | ( | castor::String const & | handler | ) |
Disables handler.
[in] | handler | The handler. |
|
inlineprotected |
Removes a handler.
[in] | handler | The handler. |
References CU_Exception, m_handlers, m_mutexHandlers, and castor::makeUniqueLock().
|
inlineprotected |
References m_handlers, m_mutexHandlers, and castor::makeUniqueLock().
|
inlineprotected |
true
if there are handlers. References m_handlers, m_mutexHandlers, and castor::makeUniqueLock().
|
inlineprotected |
Removes a handler.
[in] | handler | The handler. |
References doRemoveHandlerNL(), m_mutexHandlers, and castor::makeUniqueLock().
|
inlineprotected |
Removes a handler.
[in] | handler | The handler. |
References m_handlers.
Referenced by doRemoveHandler().
C3D_API void castor3d::UserInputListener::enableHandler | ( | castor::String const & | handler | ) |
Enables handler.
[in] | handler | The handler. |
C3D_API bool castor3d::UserInputListener::fireChar | ( | KeyboardKey | key, |
castor::String const & | c ) |
Fires a printable key event.
[in] | key | The key code. |
[in] | c | The character coorresponding to the key, displayable as is. |
true
if the event is processed by a control. C3D_API bool castor3d::UserInputListener::fireKeydown | ( | KeyboardKey | key, |
bool | ctrl, | ||
bool | alt, | ||
bool | shift ) |
Fires a keyboard key down event.
[in] | key | The key code. |
[in] | ctrl | Tells if the Ctrl key is down. |
[in] | alt | Tells if the Alt key is down. |
[in] | shift | Tells if the Shift key is down. |
true
if the event is processed by a handler. C3D_API bool castor3d::UserInputListener::fireKeyUp | ( | KeyboardKey | key, |
bool | ctrl, | ||
bool | alt, | ||
bool | shift ) |
Fires a keyboard key up event.
[in] | key | The key code. |
[in] | ctrl | Tells if the Ctrl key is down. |
[in] | alt | Tells if the Alt key is down. |
[in] | shift | Tells if the Shift key is down. |
true
if the event is processed by a control. C3D_API bool castor3d::UserInputListener::fireMouseButtonPushed | ( | MouseButton | button, |
bool | ctrl, | ||
bool | alt, | ||
bool | shift ) |
Fires a mouse pushed event.
[in] | button | The mouse button. |
[in] | ctrl | Tells if the Ctrl key is down. |
[in] | alt | Tells if the Alt key is down. |
[in] | shift | Tells if the Shift key is down. |
true
if the event is processed by a handler. C3D_API bool castor3d::UserInputListener::fireMouseButtonReleased | ( | MouseButton | button, |
bool | ctrl, | ||
bool | alt, | ||
bool | shift ) |
Fires a mouse released event.
[in] | button | The mouse button. |
[in] | ctrl | Tells if the Ctrl key is down. |
[in] | alt | Tells if the Alt key is down. |
[in] | shift | Tells if the Shift key is down. |
true
if the event is processed by a handler. C3D_API bool castor3d::UserInputListener::fireMouseMove | ( | castor::Position const & | position, |
bool | ctrl, | ||
bool | alt, | ||
bool | shift ) |
Fires a mouse move event.
[in] | position | The mouse position. |
[in] | ctrl | Tells if the Ctrl key is down. |
[in] | alt | Tells if the Alt key is down. |
[in] | shift | Tells if the Shift key is down. |
true
if the event is processed by a handler. C3D_API bool castor3d::UserInputListener::fireMouseWheel | ( | castor::Position const & | offsets, |
bool | ctrl, | ||
bool | alt, | ||
bool | shift ) |
Fires a mouse wheel event.
[in] | offsets | The mouse wheel offsets (x and y). |
[in] | ctrl | Tells if the Ctrl key is down. |
[in] | alt | Tells if the Alt key is down. |
[in] | shift | Tells if the Shift key is down. |
true
if the event is processed by a handler.
|
inline |
|
inline |
|
inline |
References m_frameListener.
|
inline |
References castor3d::MouseState::position.
C3D_API bool castor3d::UserInputListener::initialise | ( | ) |
Initialises the listener.
C3D_API void castor3d::UserInputListener::onClickAction | ( | castor::String const & | handler | ) | const |
Event raised by the handler when it is clicked, if it supports clicking.
[in] | handler | The clicked handler. |
C3D_API castor::U32String castor3d::UserInputListener::onClipboardTextAction | ( | bool | set, |
castor::U32String | text ) const |
Event raised interaction with the clipboard is needed.
[in] | set | true to define the clipboard text, false to retrieve it. |
[in] | text | The value to set the clipboard text to. |
C3D_API void castor3d::UserInputListener::onCursorAction | ( | MouseCursor | cursor | ) | const |
Event raised when mouse cursor has changed.
[in] | cursor | The cursor. |
C3D_API void castor3d::UserInputListener::onExpandAction | ( | castor::String const & | handler, |
bool | expand ) const |
Event raised by the handler when its expansion has changed.
[in] | handler | The handler. |
[in] | expand | The new value. |
C3D_API void castor3d::UserInputListener::onMouseMoveAction | ( | castor::String const & | handler | ) | const |
Event raised by the handler when the mouse is moved over it.
[in] | handler | The handler. |
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.
[in] | handler | The handler. |
[in] | index | The selection index. |
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.
[in] | handler | The handler. |
[in] | text | The new text. |
|
deletenoexcept |
|
delete |
C3D_API void castor3d::UserInputListener::processEvents | ( | ) |
Processes all queued events.
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.
[in] | handler | The clicked handler. |
[in] | function | The function. |
C3D_API void castor3d::UserInputListener::registerClipboardTextAction | ( | OnClipboardTextActionFunction | function | ) |
Registers a function to call when a clipboard event is raised by the given handler.
[in] | function | The function. |
C3D_API void castor3d::UserInputListener::registerCursorAction | ( | OnCursorActionFunction | function | ) |
Registers a function to call when a mouse cursor event is raised by the given handler.
[in] | function | The function. |
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.
[in] | handler | The handler. |
[in] | function | The function. |
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.
[in] | handler | The handler. |
[in] | function | The function. |
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.
[in] | handler | The handler. |
[in] | function | The function. |
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.
[in] | handler | The handler. |
[in] | function | The function. |
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.
[in] | handler | The clicked handler. |
C3D_API void castor3d::UserInputListener::unregisterClipboardTextAction | ( | ) |
Unregisters the function to call when a clipboard event is raised by the given handler.
C3D_API void castor3d::UserInputListener::unregisterCursorAction | ( | ) |
Unregisters the function to call when mouse cursor event is raised by the given handler.
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.
[in] | handler | The handler. |
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.
[in] | handler | The handler. |
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.
[in] | handler | The handler. |
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.
[in] | handler | The handler. |
|
protected |
The associated frame listener.
Referenced by getFrameListener().
|
protected |
The handlers array.
Referenced by doAddHandler(), doGetHandlers(), doHasHandlers(), and doRemoveHandlerNL().
|
mutableprotected |
The mutex used to protect the handlers array.
Referenced by doAddHandler(), doGetHandlers(), doHasHandlers(), and doRemoveHandler().