@@ -76,15 +76,15 @@ void ProjectScene::handleKeyPress(Qt::Key key, const QString &text)
7676 m_pressedKeys.insert (key);
7777
7878 if (m_engine) {
79- if (!text.isEmpty ()) {
80- auto it = SPECIAL_KEY_MAP.find (key);
79+ auto it = SPECIAL_KEY_MAP.find (key);
8180
82- if (it == SPECIAL_KEY_MAP.cend ())
81+ if (it == SPECIAL_KEY_MAP.cend ()) {
82+ if (!text.isEmpty ())
8383 m_engine->setKeyState (text.toStdString (), true );
84- else {
85- KeyEvent event (it->second );
86- m_engine-> setKeyState ( event.name (), true );
87- }
84+ } else {
85+ KeyEvent event (it->second );
86+ // TODO: Use event instead of even .name()
87+ m_engine-> setKeyState (event. name (), true );
8888 }
8989
9090 m_engine->setAnyKeyPressed (!m_pressedKeys.empty ());
@@ -96,15 +96,15 @@ void ProjectScene::handleKeyRelease(Qt::Key key, const QString &text)
9696 m_pressedKeys.erase (key);
9797
9898 if (m_engine) {
99- if (!text.isEmpty ()) {
100- auto it = SPECIAL_KEY_MAP.find (key);
99+ auto it = SPECIAL_KEY_MAP.find (key);
101100
102- if (it == SPECIAL_KEY_MAP.cend ())
101+ if (it == SPECIAL_KEY_MAP.cend ()) {
102+ if (!text.isEmpty ())
103103 m_engine->setKeyState (text.toStdString (), false );
104- else {
105- KeyEvent event (it->second );
106- m_engine-> setKeyState ( event.name (), false );
107- }
104+ } else {
105+ KeyEvent event (it->second );
106+ // TODO: Use event instead of even .name()
107+ m_engine-> setKeyState (event. name (), false );
108108 }
109109
110110 if (m_pressedKeys.empty ()) // avoid setting 'true' when a key is released
0 commit comments