BsShortcutManager.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #pragma once
  2. #include "BsPrerequisites.h"
  3. #include "BsModule.h"
  4. #include "BsShortcutKey.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @brief Allows you to register global keyboard shortcuts that trigger
  9. * callbacks when a certain key, or a key combination is pressed.
  10. */
  11. class BS_EXPORT ShortcutManager : public Module<ShortcutManager>
  12. {
  13. public:
  14. ShortcutManager();
  15. ~ShortcutManager();
  16. /**
  17. * @brief Registers a new shortcut key and a callback to be called when the shortcut key is triggered.
  18. */
  19. void addShortcut(const ShortcutKey& key, std::function<void()> callback);
  20. /**
  21. * @brief Removes an existing shortcut key (it's callback will no longer be triggered when this
  22. * combination is pressed).
  23. */
  24. void removeShortcut(const ShortcutKey& key);
  25. private:
  26. /**
  27. * @brief Triggered whenever a user presses a button.
  28. */
  29. void onButtonDown(const ButtonEvent& event);
  30. UnorderedMap<ShortcutKey, std::function<void()>, ShortcutKey::Hash, ShortcutKey::Equals> mShortcuts;
  31. HEvent mOnButtonDownConn;
  32. };
  33. }