MCPcopy Create free account
hub / github.com/MITK/MITK / GetModifierState

Function GetModifierState

Modules/Core/src/Interactions/mitkEventFactory.cpp:111–163  ·  view source on GitHub ↗

* @brief GetModifierState Return ModifierState as String * @param event * @return */

Source from the content-addressed store, hash-verified

109 * @return
110 */
111static std::string GetModifierState(mitk::InteractionEvent *event)
112{
113 mitk::InteractionEvent::ModifierKeys modifierKeys = mitk::InteractionEvent::NoKey;
114 std::string eventClass = event->GetNameOfClass();
115 std::transform(eventClass.cbegin(), eventClass.cend(), eventClass.begin(), ::toupper);
116 std::string strModKeys = "";
117 // TODO Add InteractionKey
118 if (eventClass == "MOUSEPRESSEVENT")
119 {
120 auto *mme = dynamic_cast<mitk::MousePressEvent *>(event);
121 modifierKeys = mme->GetModifiers();
122 }
123 if (eventClass == "MOUSERELEASEEVENT")
124 {
125 auto *mme = dynamic_cast<mitk::MouseReleaseEvent *>(event);
126 modifierKeys = mme->GetModifiers();
127 }
128 if (eventClass == "MOUSEDOUBLECLICKEVENT")
129 {
130 auto *mme = dynamic_cast<mitk::MouseDoubleClickEvent *>(event);
131 modifierKeys = mme->GetModifiers();
132 }
133 if (eventClass == "MOUSEMOVEEVENT")
134 {
135 auto *mme = dynamic_cast<mitk::MouseMoveEvent *>(event);
136 modifierKeys = mme->GetModifiers();
137 }
138 if (eventClass == "MOUSEWHEELEVENT")
139 {
140 auto *mme = dynamic_cast<mitk::MouseWheelEvent *>(event);
141 modifierKeys = mme->GetModifiers();
142 }
143
144 if (modifierKeys & mitk::InteractionEvent::ShiftKey)
145 {
146 strModKeys = "SHIFT";
147 }
148 if (modifierKeys & mitk::InteractionEvent::ControlKey)
149 {
150 if (strModKeys != "")
151 strModKeys += ",";
152
153 strModKeys += "CTRL";
154 }
155 if (modifierKeys & mitk::InteractionEvent::AltKey)
156 {
157 if (strModKeys != "")
158 strModKeys += ",";
159
160 strModKeys += "ALT";
161 }
162 return strModKeys;
163}
164
165/**
166 * @brief GetEventButton Return EventButton as String

Callers 1

EventToXMLMethod · 0.85

Calls 3

GetNameOfClassMethod · 0.45
beginMethod · 0.45
GetModifiersMethod · 0.45

Tested by

no test coverage detected