Jamba C++ API
5.1.1
|
The CView
class provides 2 methods to handle keyboard events (CView::onKeyDown
and CView::onKeyUp
) which only works as long as the view itself has focus.
More...
#include <GlobalKeyboardHook.h>
Inherits SelfContainedViewListener, and IKeyboardHook.
Public Member Functions | |
GlobalKeyboardHook ()=default | |
public constructor for the sole purpose of std::make_shared . More... | |
std::shared_ptr< GlobalKeyboardHook > | onKeyDown (KeyboardEventCallback iOnKeyDownCallback) |
Call this method to register the callback invoked on a key down event. More... | |
std::shared_ptr< GlobalKeyboardHook > | onKeyUp (KeyboardEventCallback iOnKeyUpCallback) |
Call this method to register the callback invoked on a key up event. More... | |
std::shared_ptr< SelfContainedViewListener > | registerView (CView *iView) override |
This method overrides SelfContainedViewListener::registerView to account for the fact that the frame (on which the global keyboard hook is registered) may already be available. More... | |
void | unregister () override |
If you need to unregister the keyboard hook early (meaning before the view is deleted), you can do so by calling this method. More... | |
Public Member Functions inherited from SelfContainedViewListener | |
SelfContainedViewListener ()=default | |
The constructor which unfortunately has to be declared public for the purpose of a creating a shared instance. More... | |
Static Public Member Functions | |
static std::shared_ptr< GlobalKeyboardHook > | create (CView *iView) |
Factory method to create a global keyboard hook attached to the view. More... | |
Static Public Member Functions inherited from SelfContainedViewListener | |
template<typename T , typename ... Args> | |
static std::shared_ptr< T > | create (CView *iView, Args &&...iArgs) |
This is the main method that should be used to create an instance of this class. More... | |
Protected Member Functions | |
void | maybeRegisterKeyboardHook () |
void | maybeUnregisterKeyboardHook () |
int32_t | onKeyDown (const VstKeyCode &iCode, CFrame *frame) override |
Delegate to callback. More... | |
int32_t | onKeyUp (const VstKeyCode &iCode, CFrame *frame) override |
Delegate to callback. More... | |
void | viewAttached (CView *iView) override |
Overridden to handle attaching the keyboard hook to the frame. More... | |
void | viewRemoved (CView *iView) override |
Overridden to handle detaching the keyboard hook from the frame. More... | |
Protected Member Functions inherited from SelfContainedViewListener | |
void | viewWillDelete (CView *iView) override |
Called by the view itself when it is going to be deleted. More... | |
Protected Attributes | |
CFrame * | fFrame {} |
KeyboardEventCallback | fOnKeyDownCallback {} |
KeyboardEventCallback | fOnKeyUpCallback {} |
Protected Attributes inherited from SelfContainedViewListener | |
std::shared_ptr< SelfContainedViewListener > | fThis {} |
CView * | fView {} |
The CView
class provides 2 methods to handle keyboard events (CView::onKeyDown
and CView::onKeyUp
) which only works as long as the view itself has focus.
This helper class is designed to set a keyboard hook which is global so it will work whether the view has the focus or not. This class automatically handles registering the hook to the frame (when it becomes available) and unregistering it automatically as well. As an added bonus it is possible to dynamically change the callbacks after registration.
Typical usage would be to use Views::registerGlobalKeyboardHook()
this way:
|
default |
public constructor for the sole purpose of std::make_shared
.
Do not call directly
|
inlinestatic |
Factory method to create a global keyboard hook attached to the view.
You can use the convenient global function Views::registerGlobalKeyboardHook instead.
iView | the target view of the keyboard events |
|
inlineprotected |
|
inlineprotected |
|
inline |
Call this method to register the callback invoked on a key down event.
It replaces any other if there was one and is optional.
iOnKeyDownCallback | see GUI::KeyboardEventCallback for the function definition |
|
inlineoverrideprotected |
Delegate to callback.
|
inline |
Call this method to register the callback invoked on a key up event.
It replaces any other if there was one and is optional.
iOnKeyUpCallback | see GUI::KeyboardEventCallback for the function definition |
|
inlineoverrideprotected |
Delegate to callback.
|
inlineoverridevirtual |
This method overrides SelfContainedViewListener::registerView to account for the fact that the frame (on which the global keyboard hook is registered) may already be available.
We just don't know at which point in the lifecycle of the view, this method is being called.
Reimplemented from SelfContainedViewListener.
|
inlineoverridevirtual |
If you need to unregister the keyboard hook early (meaning before the view is deleted), you can do so by calling this method.
Reimplemented from SelfContainedViewListener.
|
inlineoverrideprotected |
Overridden to handle attaching the keyboard hook to the frame.
|
inlineoverrideprotected |
Overridden to handle detaching the keyboard hook from the frame.
|
protected |
|
protected |
|
protected |