BsShortcutManager.h 1.3 KB

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