MeshLib C++ Docs
Loading...
Searching...
No Matches

#include <MRViewer/MRShortcutManager.h>

Inheritance diagram for MR::ShortcutManager:

Classes

struct  ShortcutAction
 what a shortcut does More...
struct  ShortcutCommand
 the parameter of the deprecated setShortcut overload, also the internal storage of an action More...

Public Types

enum class  Reason { Reason::KeyDown , Reason::KeyRepeat }
using ShortcutKey = MR::ShortcutKey
using Category = MR::ShortcutCategory
using ShortcutList = std::vector<std::tuple<ShortcutKey, Category, std::string>>

Public Member Functions

virtual ~ShortcutManager ()=default
virtual void setShortcut (const Shortcut &shortcut, const ShortcutAction &action)
void setShortcut (const ShortcutKey &key, const ShortcutCommand &command)
 deprecated: pass the category in (shortcut) and the rest in ShortcutAction
const ShortcutList & getShortcutList () const
bool isEnabled () const
 processShortcut does nothing if not enabled
void enable (bool on)
virtual bool processShortcut (const ShortcutKey &key, Reason=Reason::KeyDown) const
 if given key has action in shortcut map - process it and returns true, otherwise returns false;
bool onKeyDown_ (int key, int modifier) override
bool onKeyRepeat_ (int key, int modifier) override
std::optional< ShortcutKey > findShortcutByName (const std::string &name) const
 if action with given name is present in shortcut list - returns it
void clear ()
 clear all saved shortcuts
Public Member Functions inherited from MR::MultiListener< KeyDownListener, KeyRepeatListener >
virtual ~MultiListener ()=default
virtual void connect (Viewer *viewer, int group=0, boost::signals2::connect_position pos=boost::signals2::connect_position::at_back)
virtual void disconnect ()

Static Public Member Functions

static const char * getModifierString (int mod)
 make string from strictly one modifier
static std::string getKeyString (int key)
 make string from a key without modifiers, for arrow characters it uses icons font
static std::string getKeyFullString (const ShortcutKey &key, bool respectKey=true)
 make string from all modifiers and with/without key and returns it
static std::optional< int > parseKey (std::string_view name)
static std::optional< int > parseModifier (std::string_view name)
static std::optional< Category > parseCategory (std::string_view name)
static std::optional< ShortcutKey > parseShortcutKey (std::string_view keys)

Static Public Attributes

static const std::string categoryNames [6] = { "Info", "Edit", "View", "Scene", "Objects", "Selection " }

Protected Types

using ShourtcutsMap = HashMap<int, ShortcutCommand>
using ShourtcutsBackMap = HashMap<std::string, int>

Static Protected Member Functions

static int mapKeyFromKeyAndMod (const ShortcutKey &key, bool respectKeyboard)
static ShortcutKey kayAndModFromMapKey (int mapKey)
 returns key with modifier (alt, ctrl, shift, etc.) from simple map key

Protected Attributes

bool enabled_ { true }
ShourtcutsMap map_
ShourtcutsBackMap backMap_
std::optional< ShortcutList > listCache_

Detailed Description

this class stores two maps: 1) shortcut to action 2) action name to shortcut it can be used to process, customize and print shortcuts indifferent to literals register


The documentation for this class was generated from the following file: