MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
ManagedKeyboardShortcut.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2014, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef MANAGED_KEYBOARD_SHORTCUT_H
14#define MANAGED_KEYBOARD_SHORTCUT_H
15
16#include "SoInteraction.h"
17
18#include <ThirdPartyWarningsDisable.h>
19#include <Inventor/events/SoKeyboardEvent.h>
20
21#include <map>
22#include <ThirdPartyWarningsRestore.h>
23
27{
28public:
31 : _modifiers(0)
32 , _key(SoKeyboardEvent::ANY)
33 {}
34
36 ManagedKeyboardShortcut(int modifiers, SoKeyboardEvent::Key key)
37 : _modifiers(modifiers)
38 , _key(key)
39 {}
40
42 bool matches(int modifiers, SoKeyboardEvent::Key key) const;
43
45 bool isValid() const;
46
48 int getModifiers() const
49 {
50 return _modifiers;
51 }
52
54 SoKeyboardEvent::Key getKey() const
55 {
56 return _key;
57 }
58
60 std::string toString() const;
61
66 static ManagedKeyboardShortcut fromString(const std::string& s);
67
68
69private:
71 int _modifiers;
72 SoKeyboardEvent::Key _key;
73
74 static void _populateKeyMap();
75 static void _setKeyMapEntry(const char* cname, SoKeyboardEvent::Key key);
76
77 static std::map<std::string, SoKeyboardEvent::Key> _keyCodeMap;
78 static std::map<SoKeyboardEvent::Key, std::string> _keyNameMap;
79
81 static SoKeyboardEvent::Key _getKeyCodeForName(const std::string& keyName);
83 static std::string _getKeyNameForCode(SoKeyboardEvent::Key keyCode);
84
88 static bool decodeKeyString(const std::string& keyCombo, int& modifiers, SoKeyboardEvent::Key& nKey);
89};
90
91#endif // __ManagedKeyboardShortcut_H
@ ANY
Special constant for any key.
#define SOMANAGEDINTERACTION_API
File to resolve system dependencies in View2D library.
ManagedActionTrigger is a base class for all triggers of managed interactions.
Class ManagedKeyboardShortcut encapsulates the combination of modifier keys and another key that acti...
static ManagedKeyboardShortcut fromString(const std::string &s)
Creates a shortcut from a string.
int getModifiers() const
Returns the required key modifiers.
std::string toString() const
Returns a string representation of this shortcut (see fromString()).
ManagedKeyboardShortcut(int modifiers, SoKeyboardEvent::Key key)
Creates shortcut with given key and key modifiers; see SoInteraction for possible key modifiers.
bool matches(int modifiers, SoKeyboardEvent::Key key) const
Returns whether the shortcut matches the given modifiers and key; see SoInteraction for possible modi...
ManagedKeyboardShortcut()
The default constructor creates an invalid shortcut.
SoKeyboardEvent::Key getKey() const
Returns the required key.
bool isValid() const
Returns whether the shortcut is valid.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.