21#include <vstgui4/vstgui/lib/cframe.h>
22#include <vstgui4/vstgui/lib/events.h>
28using namespace VSTGUI;
68 return std::dynamic_pointer_cast<GlobalKeyboardHook>(shared_from_this());
78 static std::shared_ptr<GlobalKeyboardHook>
create(CView *iView)
88 std::shared_ptr<SelfContainedViewListener>
registerView(CView *iView)
override
101 DCHECK_F(iView ==
fView);
110 DCHECK_F(iView ==
fView);
138 fFrame->registerKeyboardHook(
this);
148 fFrame->unregisterKeyboardHook(
this);
void maybeRegisterKeyboardHook()
Definition GlobalKeyboardHook.h:131
std::shared_ptr< GlobalKeyboardHook > onKeyboardEvent(KeyboardEventCallback iOnKeyboardEventCallback)
Call this method to register the callback invoked on a keyboard event.
Definition GlobalKeyboardHook.h:65
std::shared_ptr< SelfContainedViewListener > registerView(CView *iView) override
This method overrides SelfContainedViewListener::registerView to account for the fact that the frame ...
Definition GlobalKeyboardHook.h:88
void viewAttached(CView *iView) override
Overridden to handle attaching the keyboard hook to the frame.
Definition GlobalKeyboardHook.h:99
GlobalKeyboardHook()=default
public constructor for the sole purpose of std::make_shared.
CFrame * fFrame
Definition GlobalKeyboardHook.h:163
void viewRemoved(CView *iView) override
Overridden to handle detaching the keyboard hook from the frame.
Definition GlobalKeyboardHook.h:108
void unregister() override
If you need to unregister the keyboard hook early (meaning before the view is deleted),...
Definition GlobalKeyboardHook.h:119
KeyboardEventCallback fOnKeyboardEventCallback
Definition GlobalKeyboardHook.h:164
void onKeyboardEvent(KeyboardEvent &event, CFrame *frame) override
Delegate to callback.
Definition GlobalKeyboardHook.h:156
static std::shared_ptr< GlobalKeyboardHook > create(CView *iView)
Factory method to create a global keyboard hook attached to the view.
Definition GlobalKeyboardHook.h:78
void maybeUnregisterKeyboardHook()
Definition GlobalKeyboardHook.h:144
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.
Definition SelfContainedViewListener.h:100
SelfContainedViewListener()=default
The constructor which unfortunately has to be declared public for the purpose of a creating a shared ...
CView * fView
Definition SelfContainedViewListener.h:164
virtual std::shared_ptr< SelfContainedViewListener > registerView(CView *iView)
Registers this class as a view listener.
Definition SelfContainedViewListener.h:135
virtual void unregister()
You can call this method at anytime to unregister this class as the listener to the view that was pre...
Definition SelfContainedViewListener.h:115
Definition CustomController.h:25
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
std::function< void(KeyboardEvent &)> KeyboardEventCallback
Used to register global keyboard hooks.
Definition Types.h:68