Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

fix navigation mode states

konerof22b87774bd1
diff --git a/toonz/sources/include/tools/toolhandle.h b/toonz/sources/include/tools/toolhandle.h
index 0f818846c..353533c7c 100644
--- a/toonz/sources/include/tools/toolhandle.h
+++ b/toonz/sources/include/tools/toolhandle.h
@@ -31,21 +31,25 @@ class QString;
class DVAPI ToolHandle final : public QObject {
Q_OBJECT
+ // Core tool state
TTool *m_tool;
QString m_toolName;
int m_toolTargetType;
+
+ // Navigation state
+ struct NavigationState {
+ bool active = false; // Whether navigation mode is active
+ QString originalTool; // Tool to restore when exiting navigation
+ bool spacePressed = false; // Space key state
+ bool shiftPressed = false; // Shift key state
+ bool ctrlPressed = false; // Ctrl key state
+ } m_navState;
+
QString m_storedToolName;
QElapsedTimer m_storedToolTime;
QString m_oldToolName;
bool m_toolIsBusy;
- // State tracking for intuitive viewer navigation
- QString m_originalTool; // Store tool before navigation mode
- bool m_inNavigationMode = false;
- bool m_spacePressed = false;
- bool m_shiftPressed = false;
- bool m_ctrlPressed = false;
-
public:
ToolHandle();
~ToolHandle();
@@ -56,13 +60,12 @@ public:
const QString &getRequestedToolName() const { return m_toolName; }
- // used to handle viewer navigation state
+ // Navigation methods
void setSpacePressed(bool pressed);
void setShiftPressed(bool pressed);
void setCtrlPressed(bool pressed);
- bool isSpacePressed() const { return m_spacePressed; }
- bool isShiftPressed() const { return m_shiftPressed; }
- bool isCtrlPressed() const { return m_ctrlPressed; }
+ bool isSpacePressed() const { return m_navState.spacePressed; }
+ bool isNavigating() const { return m_navState.active; }
// used to change tool for a short while (e.g. while keeping pressed a
// short-key)
@@ -86,7 +89,9 @@ public:
}
private:
- void updateNavigationState();
+ // Navigation methods
+ void updateNavigationTool(); // Select appropriate navigation tool
+ void exitNavigation(); // Clean exit from navigation mode
signals:
void toolComboBoxListChanged(std::string);
diff --git a/toonz/sources/tnztools/toolhandle.cpp b/toonz/sources/tnztools/toolhandle.cpp
index 90d8b04ea..3e6ee8f01 100644
--- a/toonz/sources/tnztools/toolhandle.cpp
+++ b/toonz/sources/tnztools/toolhandle.cpp
@@ -8,6 +8,7 @@
// #include "tapp.h"
#include "toonzqt/menubarcommand.h"
#include "toonz/preferences.h"
+#include <QGuiApplication>
#include <QAction>
#include <QMap>
#include <QDebug>
@@ -34,12 +35,6 @@ TTool *ToolHandle::getTool() const { return m_tool; }
//-----------------------------------------------------------------------------
void ToolHandle::setTool(QString name) {
- // If we're in navigation mode, only allow navigation-related tool changes
- if (m_inNavigationMode && name != "T_Hand" && name != "T_Rotate" &&
- name != "T_Zoom") {
- return;
- }
-
m_oldToolName = m_toolName = name;
TTool *tool = TTool::getTool(m_toolName.toStdString(),
@@ -70,55 +65,97 @@ void ToolHandle::setTool(QString name) {
//-----------------------------------------------------------------------------
void ToolHandle::setSpacePressed(bool pressed) {
- if (m_spacePressed == pressed) return;
+ if (m_navState.spacePressed == pressed) return;
+
+ m_navState.spacePressed = pressed;
- m_spacePressed = pressed;
if (pressed) {
- // Store current tool when entering navigation mode
- m_originalTool = m_toolName;
- m_inNavigationMode = true;
- setTool("T_Hand");
- } else {
- // Restore original tool when exiting navigation mode
- m_inNavigationMode = false;
- // Reset all modifier states when exiting navigation mode
- m_ctrlPressed = false;
- m_shiftPressed = false;
- if (!m_originalTool.isEmpty()) {
- setTool(m_originalTool);
- m_originalTool.clear();
+ // Enter navigation mode
+ if (!m_navState.active) {
+ m_navState.active = true;
+ m_navState.originalTool = m_toolName;
}
+
+ /**
+ * Check actual keyboard state to detect "buffered" modifier keys
+ * ______________________________________________________________
+ *
+ * Normally, we track modifier keys using 'setShiftPressed()' and
+ * 'setCtrlPressed()' when the user presses them. However, there's a case
+ * where a user [holds Shift or Ctrl before pressing Space]. In this case:
+ *
+ * - The Shift/Ctrl state might already be active 'before' space was pressed
+ * - If we don't check the keyboard state here, we'd assume Shift/Ctrl off
+ * - This would result in the wrong tool being selected (e.g., T_Hand
+ * instead of T_Rotate)
+ *
+ * Example scenario:
+ * 1. User 'holds Shift' but 'setShiftPressed(true)' is not yet called
+ * 2. Pressed 'Space' -> navigation activates
+ * 3. If we don't check the keyboard here, we don't recognize Shift is held
+ * 4. The tool defaults to 'T_Hand' instead of 'T_Rotate' (incorrect!)
+ *
+ * This prevents that issue by explicitly checking what modifier keys are
+ * actually held.
+ */
+ m_navState.shiftPressed =
+ (QGuiApplication::queryKeyboardModifiers() & Qt::ShiftModifier) != 0;
+ m_navState.ctrlPressed =
+ (QGuiApplication::queryKeyboardModifiers() & Qt::ControlModifier) != 0;
+
+ updateNavigationTool(); // Select the correct tool based on modifiers
+ } else {
+ exitNavigation();
}
- updateNavigationState();
}
void ToolHandle::setShiftPressed(bool pressed) {
- if (m_shiftPressed == pressed) return;
+ if (m_navState.shiftPressed == pressed) return;
+
+ m_navState.shiftPressed = pressed;
- m_shiftPressed = pressed;
- updateNavigationState();
+ // If we're in navigation mode, update the tool selection
+ if (m_navState.active) {
+ updateNavigationTool();
+ }
}
void ToolHandle::setCtrlPressed(bool pressed) {
- if (m_ctrlPressed == pressed) return;
+ if (m_navState.ctrlPressed == pressed) return;
+
+ m_navState.ctrlPressed = pressed;
+
+ // If we're in navigation mode, update the tool selection
+ if (m_navState.active) {
+ updateNavigationTool();
+ }
+}
+
+void ToolHandle::updateNavigationTool() {
+ if (!m_navState.active) return; // Only update if navigation mode is active
- m_ctrlPressed = pressed;
- updateNavigationState();
+ // Priority: Ctrl > Shift > Default (T_Hand)
+ if (m_navState.ctrlPressed) {
+ setTool("T_Zoom");
+ } else if (m_navState.shiftPressed) {
+ setTool("T_Rotate");
+ } else {
+ setTool("T_Hand");
+ }
}
-void ToolHandle::updateNavigationState() {
- // Only handle state changes when in navigation mode
- if (!m_inNavigationMode) return;
-
- if (m_spacePressed) {
- if (m_ctrlPressed) {
- setTool("T_Zoom");
- } else if (m_shiftPressed) {
- setTool("T_Rotate");
- } else {
- setTool("T_Hand");
- }
+void ToolHandle::exitNavigation() {
+ if (!m_navState.active) return;
+
+ // Restore the original tool before navigation mode was activated
+ if (!m_navState.originalTool.isEmpty()) {
+ setTool(m_navState.originalTool);
+ m_storedToolName = m_navState.originalTool;
}
+
+ // Reset navigation mode but PRESERVE modifier states for buffering
+ m_navState.active = false;
+ m_navState.spacePressed = false;
}
//-----------------------------------------------------------------------------
@@ -131,16 +168,11 @@ void ToolHandle::storeTool() {
//-----------------------------------------------------------------------------
void ToolHandle::restoreTool() {
- if (m_storedToolName != m_toolName && m_storedToolName != "") {
- // Only bypass timer when in navigation mode
- if (m_inNavigationMode) {
- setTool(m_storedToolName);
- }
- // For all other cases, use the timer check
- else if (m_storedToolTime.elapsed() >
- Preferences::instance()->getTempToolSwitchTimer()) {
- setTool(m_storedToolName);
- }
+ // qDebug() << m_storedToolTime.elapsed();
+ if (m_storedToolName != m_toolName && m_storedToolName != "" &&
+ m_storedToolTime.elapsed() >
+ Preferences::instance()->getTempToolSwitchTimer()) {
+ setTool(m_storedToolName);
}
}
diff --git a/toonz/sources/toonz/sceneviewerevents.cpp b/toonz/sources/toonz/sceneviewerevents.cpp
index 451454e54..56880c597 100644
--- a/toonz/sources/toonz/sceneviewerevents.cpp
+++ b/toonz/sources/toonz/sceneviewerevents.cpp
@@ -1419,195 +1419,212 @@ void SceneViewer::keyPressEvent(QKeyEvent *event) {
if (m_freezedStatus != NO_FREEZED) return;
int key = event->key();
- // Handle navigation keys first
+ // Handle only initial key presses, not auto-repeat
if (!event->isAutoRepeat()) {
- if (event->key() == Qt::Key_Space) {
- TApp::instance()->getCurrentTool()->setSpacePressed(true);
+ ToolHandle *toolHandle = TApp::instance()->getCurrentTool();
+
+ switch (event->key()) {
+ case Qt::Key_Space:
+ toolHandle->setSpacePressed(true);
event->accept();
return;
- }
- if (event->key() == Qt::Key_Control) {
- TApp::instance()->getCurrentTool()->setCtrlPressed(true);
+
+ case Qt::Key_Control:
+ toolHandle->setCtrlPressed(true);
event->accept();
return;
- }
- if (event->key() == Qt::Key_Shift) {
- TApp::instance()->getCurrentTool()->setShiftPressed(true);
+
+ case Qt::Key_Shift:
+ toolHandle->setShiftPressed(true);
event->accept();
return;
}
}
- // Handle Canon camera controls if enabled
-#ifdef WITH_CANON
- if ((m_stopMotion->m_canon->m_pickLiveViewZoom ||
- m_stopMotion->m_canon->m_zooming) &&
- (key == Qt::Key_Left || key == Qt::Key_Right || key == Qt::Key_Up ||
- key == Qt::Key_Down || key == Qt::Key_2 || key == Qt::Key_4 ||
- key == Qt::Key_6 || key == Qt::Key_8)) {
- // Handle camera zoom point adjustment
- if (m_stopMotion->m_canon->m_liveViewZoomReadyToPick == true) {
- if (key == Qt::Key_Left || key == Qt::Key_4) {
- m_stopMotion->m_canon->m_liveViewZoomPickPoint.x -= 10;
- }
- if (key == Qt::Key_Right || key == Qt::Key_6) {
- m_stopMotion->m_canon->m_liveViewZoomPickPoint.x += 10;
- }
- if (key == Qt::Key_Up || key == Qt::Key_8) {
- m_stopMotion->m_canon->m_liveViewZoomPickPoint.y += 10;
- }
- if (key == Qt::Key_Down || key == Qt::Key_2) {
- m_stopMotion->m_canon->m_liveViewZoomPickPoint.y -= 10;
- }
- if (m_stopMotion->m_canon->m_zooming) {
- m_stopMotion->m_canon->setZoomPoint();
+ // Check if we're in navigation mode before handling any other keys
+ ToolHandle *toolHandle = TApp::instance()->getCurrentTool();
+ if (!toolHandle->isNavigating()) {
+ if (event->type() == QEvent::ShortcutOverride ||
+ event->type() == QEvent::KeyPress) {
+ if (!event->isAutoRepeat()) {
+ TApp::instance()->getCurrentTool()->storeTool();
}
}
- m_stopMotion->m_canon->calculateZoomPoint();
- event->accept();
- return;
- } else if (m_stopMotion->m_canon->m_pickLiveViewZoom &&
- (key == Qt::Key_Escape || key == Qt::Key_Enter ||
- key == Qt::Key_Return)) {
- m_stopMotion->m_canon->toggleZoomPicking();
- event->accept();
- return;
- } else
+
+ // Handle Canon camera controls if enabled
+#ifdef WITH_CANON
+ if ((m_stopMotion->m_canon->m_pickLiveViewZoom ||
+ m_stopMotion->m_canon->m_zooming) &&
+ (key == Qt::Key_Left || key == Qt::Key_Right || key == Qt::Key_Up ||
+ key == Qt::Key_Down || key == Qt::Key_2 || key == Qt::Key_4 ||
+ key == Qt::Key_6 || key == Qt::Key_8)) {
+ // Handle camera zoom point adjustment
+ if (m_stopMotion->m_canon->m_liveViewZoomReadyToPick == true) {
+ if (key == Qt::Key_Left || key == Qt::Key_4) {
+ m_stopMotion->m_canon->m_liveViewZoomPickPoint.x -= 10;
+ }
+ if (key == Qt::Key_Right || key == Qt::Key_6) {
+ m_stopMotion->m_canon->m_liveViewZoomPickPoint.x += 10;
+ }
+ if (key == Qt::Key_Up || key == Qt::Key_8) {
+ m_stopMotion->m_canon->m_liveViewZoomPickPoint.y += 10;
+ }
+ if (key == Qt::Key_Down || key == Qt::Key_2) {
+ m_stopMotion->m_canon->m_liveViewZoomPickPoint.y -= 10;
+ }
+ if (m_stopMotion->m_canon->m_zooming) {
+ m_stopMotion->m_canon->setZoomPoint();
+ }
+ }
+ m_stopMotion->m_canon->calculateZoomPoint();
+ event->accept();
+ return;
+ } else if (m_stopMotion->m_canon->m_pickLiveViewZoom &&
+ (key == Qt::Key_Escape || key == Qt::Key_Enter ||
+ key == Qt::Key_Return)) {
+ m_stopMotion->m_canon->toggleZoomPicking();
+ event->accept();
+ return;
+ } else
#endif
- // Handle stop motion capture
+ // Handle stop motion capture
#if defined(x64)
- if (m_stopMotion->m_liveViewStatus == 2 &&
- (key == Qt::Key_Enter || key == Qt::Key_Return)) {
- m_stopMotion->captureImage();
- event->accept();
- return;
- }
+ if (m_stopMotion->m_liveViewStatus == 2 &&
+ (key == Qt::Key_Enter || key == Qt::Key_Return)) {
+ m_stopMotion->captureImage();
+ event->accept();
+ return;
+ }
#endif
- // Handle tool-specific key events and viewer shortcuts
- auto ret = [&]() -> bool {
- TTool *tool = TApp::instance()->getCurrentTool()->getTool();
- if (!tool) return false;
-
- bool isTextToolActive = tool->getName() == T_Type && tool->isActive();
-
- // Handle non-text tool shortcuts
- if (!isTextToolActive) {
- if (ViewerZoomer(this).exec(event)) return true;
- if (SceneViewerShortcutReceiver(this).exec(event)) return true;
-
- // Handle style switching shortcuts when appropriate
- if (m_isStyleShortcutSwitchable &&
- Preferences::instance()->isUseNumpadForSwitchingStylesEnabled() &&
- (event->modifiers() == Qt::NoModifier ||
- event->modifiers() == Qt::ShiftModifier ||
- event->modifiers() == Qt::KeypadModifier) &&
- ((Qt::Key_0 <= key && key <= Qt::Key_9) || key == Qt::Key_Tab ||
- key == Qt::Key_Backtab)) {
- // Handle fullscreen style shortcuts
- if (parentWidget() &&
- parentWidget()->windowState() & Qt::WindowFullScreen) {
- StyleShortcutSwitchablePanel::onKeyPress(event);
+ // Handle tool-specific key events and viewer shortcuts
+ auto ret = [&]() -> bool {
+ TTool *tool = TApp::instance()->getCurrentTool()->getTool();
+ if (!tool) return false;
+
+ bool isTextToolActive = tool->getName() == T_Type && tool->isActive();
+
+ // Handle non-text tool shortcuts
+ if (!isTextToolActive) {
+ if (ViewerZoomer(this).exec(event)) return true;
+ if (SceneViewerShortcutReceiver(this).exec(event)) return true;
+
+ // Handle style switching shortcuts when appropriate
+ if (m_isStyleShortcutSwitchable &&
+ Preferences::instance()->isUseNumpadForSwitchingStylesEnabled() &&
+ (event->modifiers() == Qt::NoModifier ||
+ event->modifiers() == Qt::ShiftModifier ||
+ event->modifiers() == Qt::KeypadModifier) &&
+ ((Qt::Key_0 <= key && key <= Qt::Key_9) || key == Qt::Key_Tab ||
+ key == Qt::Key_Backtab)) {
+ // Handle fullscreen style shortcuts
+ if (parentWidget() &&
+ parentWidget()->windowState() & Qt::WindowFullScreen) {
+ StyleShortcutSwitchablePanel::onKeyPress(event);
+ return true;
+ }
+
+ event->ignore();
return true;
}
- event->ignore();
- return true;
- }
-
- // Handle onion skin ghost flip keys
- if (CommandManager::instance()->getAction(MI_ShiftTrace)->isChecked() &&
- (Qt::Key_F1 <= key && key <= Qt::Key_F3)) {
- OnionSkinMask osm =
- TApp::instance()->getCurrentOnionSkin()->getOnionSkinMask();
- if (osm.getGhostFlipKey() != key) {
- osm.appendGhostFlipKey(key);
- TApp::instance()->getCurrentOnionSkin()->setOnionSkinMask(osm);
- TApp::instance()->getCurrentOnionSkin()->notifyOnionSkinMaskChanged();
+ // Handle onion skin ghost flip keys
+ if (CommandManager::instance()->getAction(MI_ShiftTrace)->isChecked() &&
+ (Qt::Key_F1 <= key && key <= Qt::Key_F3)) {
+ OnionSkinMask osm =
+ TApp::instance()->getCurrentOnionSkin()->getOnionSkinMask();
+ if (osm.getGhostFlipKey() != key) {
+ osm.appendGhostFlipKey(key);
+ TApp::instance()->getCurrentOnionSkin()->setOnionSkinMask(osm);
+ TApp::instance()
+ ->getCurrentOnionSkin()
+ ->notifyOnionSkinMaskChanged();
+ }
+ return true;
}
- return true;
}
- }
- if (!tool->isEnabled()) return false;
+ if (!tool->isEnabled()) return false;
- tool->setViewer(this);
+ tool->setViewer(this);
- // Handle modifier keys that require immediate cursor updates
- if (key == Qt::Key_Shift || key == Qt::Key_Control || key == Qt::Key_Alt ||
- key == Qt::Key_AltGr) {
- TMouseEvent toonzEvent;
- initToonzEvent(toonzEvent, event);
- toonzEvent.m_pos = TPointD(m_lastMousePos.x(),
- (double)(height() - 1) - m_lastMousePos.y());
+ // Handle modifier keys that require immediate cursor updates
+ if (key == Qt::Key_Shift || key == Qt::Key_Control ||
+ key == Qt::Key_Alt || key == Qt::Key_AltGr) {
+ TMouseEvent toonzEvent;
+ initToonzEvent(toonzEvent, event);
+ toonzEvent.m_pos = TPointD(m_lastMousePos.x(),
+ (double)(height() - 1) - m_lastMousePos.y());
- TPointD pos = tool->getMatrix().inv() * winToWorld(m_lastMousePos);
+ TPointD pos = tool->getMatrix().inv() * winToWorld(m_lastMousePos);
- TObjectHandle *objHandle = TApp::instance()->getCurrentObject();
- if ((tool->getToolType() & TTool::LevelTool) && !objHandle->isSpline()) {
- pos.x /= m_dpiScale.x;
- pos.y /= m_dpiScale.y;
- }
+ TObjectHandle *objHandle = TApp::instance()->getCurrentObject();
+ if ((tool->getToolType() & TTool::LevelTool) &&
+ !objHandle->isSpline()) {
+ pos.x /= m_dpiScale.x;
+ pos.y /= m_dpiScale.y;
+ }
- tool->mouseMove(pos, toonzEvent);
- setToolCursor(this, tool->getCursorId());
- }
+ tool->mouseMove(pos, toonzEvent);
+ setToolCursor(this, tool->getCursorId());
+ }
- if (key == Qt::Key_Menu || key == Qt::Key_Meta) return false;
-
- return tool->keyDown(event);
- }();
-
- // Handle frame navigation if no tool handled the key
- if (!ret) {
- if (changeFrameSkippingHolds(event)) return;
-
- TFrameHandle *fh = TApp::instance()->getCurrentFrame();
- int origFrame = fh->getFrame();
-
- // Handle frame navigation keys
- if (key == Qt::Key_Up || key == Qt::Key_Left)
- fh->prevFrame();
- else if (key == Qt::Key_Down || key == Qt::Key_Right) {
- // Allow creating new frames with down arrow in level mode
- TFrameId newId = 0;
- if (Preferences::instance()->getDownArrowLevelStripNewFrame() &&
- fh->getFrameType() == TFrameHandle::LevelFrame) {
- TXshSimpleLevel *level =
- TApp::instance()->getCurrentLevel()->getLevel()->getSimpleLevel();
- if (level) {
- std::vector<TFrameId> fids;
- level->getFids(fids);
- if (!fids.empty()) {
- int frameCount = (int)fids.size();
- newId = level->index2fid(frameCount);
+ if (key == Qt::Key_Menu || key == Qt::Key_Meta) return false;
+
+ return tool->keyDown(event);
+ }();
+
+ // Handle frame navigation if no tool handled the key
+ if (!ret) {
+ if (changeFrameSkippingHolds(event)) return;
+
+ TFrameHandle *fh = TApp::instance()->getCurrentFrame();
+ int origFrame = fh->getFrame();
+
+ // Handle frame navigation keys
+ if (key == Qt::Key_Up || key == Qt::Key_Left)
+ fh->prevFrame();
+ else if (key == Qt::Key_Down || key == Qt::Key_Right) {
+ // Allow creating new frames with down arrow in level mode
+ TFrameId newId = 0;
+ if (Preferences::instance()->getDownArrowLevelStripNewFrame() &&
+ fh->getFrameType() == TFrameHandle::LevelFrame) {
+ TXshSimpleLevel *level =
+ TApp::instance()->getCurrentLevel()->getLevel()->getSimpleLevel();
+ if (level) {
+ std::vector<TFrameId> fids;
+ level->getFids(fids);
+ if (!fids.empty()) {
+ int frameCount = (int)fids.size();
+ newId = level->index2fid(frameCount);
+ }
}
}
- }
- fh->nextFrame(newId);
- } else if (key == Qt::Key_Home)
- fh->firstFrame();
- else if (key == Qt::Key_End)
- fh->lastFrame();
-
- // Handle cell selection movement with arrow keys
- if (Preferences::instance()->isUseArrowKeyToShiftCellSelectionEnabled() &&
- fh->getFrameType() != TFrameHandle::LevelFrame) {
- TCellSelection *cellSel =
- dynamic_cast<TCellSelection *>(TSelection::getCurrent());
- if (cellSel && !cellSel->isEmpty()) {
- int r0, c0, r1, c1;
- cellSel->getSelectedCells(r0, c0, r1, c1);
- int shiftFrame = fh->getFrame() - origFrame;
-
- cellSel->selectCells(r0 + shiftFrame, c0, r1 + shiftFrame, c1);
- TApp::instance()->getCurrentSelection()->notifySelectionChanged();
+ fh->nextFrame(newId);
+ } else if (key == Qt::Key_Home)
+ fh->firstFrame();
+ else if (key == Qt::Key_End)
+ fh->lastFrame();
+
+ // Handle cell selection movement with arrow keys
+ if (Preferences::instance()->isUseArrowKeyToShiftCellSelectionEnabled() &&
+ fh->getFrameType() != TFrameHandle::LevelFrame) {
+ TCellSelection *cellSel =
+ dynamic_cast<TCellSelection *>(TSelection::getCurrent());
+ if (cellSel && !cellSel->isEmpty()) {
+ int r0, c0, r1, c1;
+ cellSel->getSelectedCells(r0, c0, r1, c1);
+ int shiftFrame = fh->getFrame() - origFrame;
+
+ cellSel->selectCells(r0 + shiftFrame, c0, r1 + shiftFrame, c1);
+ TApp::instance()->getCurrentSelection()->notifySelectionChanged();
+ }
}
}
- }
- update();
+ update();
+ }
}
//-----------------------------------------------------------------------------
@@ -1622,19 +1639,23 @@ void SceneViewer::keyReleaseEvent(QKeyEvent *event) {
int key = event->key();
- // Handle navigation keys first
+ // Handle only real key releases, not auto-repeat
if (!event->isAutoRepeat()) {
- if (event->key() == Qt::Key_Space) {
- TApp::instance()->getCurrentTool()->setSpacePressed(false);
+ ToolHandle *toolHandle = TApp::instance()->getCurrentTool();
+
+ switch (event->key()) {
+ case Qt::Key_Space:
+ toolHandle->setSpacePressed(false);
event->accept();
return;
- }
- if (event->key() == Qt::Key_Control) {
- TApp::instance()->getCurrentTool()->setCtrlPressed(false);
+
+ case Qt::Key_Control:
+ toolHandle->setCtrlPressed(false);
event->accept();
- }
- if (event->key() == Qt::Key_Shift) {
- TApp::instance()->getCurrentTool()->setShiftPressed(false);
+ return;
+
+ case Qt::Key_Shift:
+ toolHandle->setShiftPressed(false);
event->accept();
return;
}