The CView class provides a method to handle keyboard events (CView::onKeyboardEvent) which only works as long as the view itself has focus.
More...
#include <GlobalKeyboardHook.h>
Inherits SelfContainedViewListener, and IKeyboardHook.
|
| static std::shared_ptr< GlobalKeyboardHook > | create (CView *iView) |
| | Factory method to create a global keyboard hook attached to the view.
|
| 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.
|
The CView class provides a method to handle keyboard events (CView::onKeyboardEvent) 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:
{
if(iEvent.character == 'z'
&& iEvent.type == VSTGUI::EventType::KeyDown
&& iEvent.modifiers.empty())
{
zoomToSelection();
iEvent.consumed = true;
}
});
virtual void initState(GUIState *iGUIState)
Called during initialization.
Definition ParamAware.cpp:37
std::shared_ptr< GlobalKeyboardHook > registerGlobalKeyboardHook(CView *iView)
This is the main entry point that you should use to register a global keyboard hook.
Definition GlobalKeyboardHook.h:174
◆ GlobalKeyboardHook()
public constructor for the sole purpose of std::make_shared.
Do not call directly
◆ create()
Factory method to create a global keyboard hook attached to the view.
You can use the convenient global function Views::registerGlobalKeyboardHook instead.
- Parameters
-
| iView | the target view of the keyboard events |
- Returns
- the helper class to register callback on
◆ maybeRegisterKeyboardHook()
| void maybeRegisterKeyboardHook |
( |
| ) |
|
|
inlineprotected |
◆ maybeUnregisterKeyboardHook()
| void maybeUnregisterKeyboardHook |
( |
| ) |
|
|
inlineprotected |
◆ onKeyboardEvent() [1/2]
| void onKeyboardEvent |
( |
KeyboardEvent & | event, |
|
|
CFrame * | frame ) |
|
inlineoverrideprotected |
◆ onKeyboardEvent() [2/2]
Call this method to register the callback invoked on a keyboard event.
It replaces any other if there was one and is optional.
- Parameters
-
- Returns
- itself (as a shared pointer) for chaining calls (see example at the top)
◆ registerView()
◆ unregister()
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.
◆ viewAttached()
| void viewAttached |
( |
CView * | iView | ) |
|
|
inlineoverrideprotected |
Overridden to handle attaching the keyboard hook to the frame.
◆ viewRemoved()
| void viewRemoved |
( |
CView * | iView | ) |
|
|
inlineoverrideprotected |
Overridden to handle detaching the keyboard hook from the frame.
◆ fFrame
◆ fOnKeyboardEventCallback
The documentation for this class was generated from the following file: