1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#pragma once
4
5#include "BsPrerequisites.h"
6#include "Utility/BsModule.h"
7#include "GUI/BsShortcutKey.h"
8
9namespace bs
10{
11 /** @addtogroup GUI-Internal
12 * @{
13 */
14
15 /**
16 * Allows you to register global keyboard shortcuts that trigger callbacks when a certain key, or a key combination is
17 * pressed.
18 */
19 class BS_EXPORT ShortcutManager : public Module<ShortcutManager>
20 {
21 public:
22 ShortcutManager();
23 ~ShortcutManager();
24
25 /** Registers a new shortcut key and a callback to be called when the shortcut key is triggered. */
26 void addShortcut(const ShortcutKey& key, std::function<void()> callback);
27
28 /** Removes an existing shortcut key (it's callback will no longer be triggered when this combination is pressed). */
29 void removeShortcut(const ShortcutKey& key);
30
31 private:
32 /** Triggered whenever a user presses a button. */
33 void onButtonDown(const ButtonEvent& event);
34
35 UnorderedMap<ShortcutKey, std::function<void()>, ShortcutKey::Hash, ShortcutKey::Equals> mShortcuts;
36 HEvent mOnButtonDownConn;
37 };
38
39 /** @} */
40}