From 37cf8051a4dec9bbaddd17ca07d846b3e5016a99 Mon Sep 17 00:00:00 2001 From: Patrick Roncagliolo Date: Wed, 21 Aug 2024 09:47:31 +0200 Subject: [PATCH] Handle `Tool::Finished` returned by `processKeyEvent` (#1257) --- rviz_common/src/rviz_common/tool_manager.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rviz_common/src/rviz_common/tool_manager.cpp b/rviz_common/src/rviz_common/tool_manager.cpp index 2ba436fbb..eb29a4c5a 100644 --- a/rviz_common/src/rviz_common/tool_manager.cpp +++ b/rviz_common/src/rviz_common/tool_manager.cpp @@ -158,6 +158,7 @@ void ToolManager::handleChar(QKeyEvent * event, RenderPanel * panel) tool = shortkey_to_tool_map_[event->key()]; } + int flags = 0; if (tool) { // if there is a incoming tool check if it matches the current tool if (current_tool_ == tool) { @@ -167,7 +168,7 @@ void ToolManager::handleChar(QKeyEvent * event, RenderPanel * panel) // if no, check if the current tool accesses all key events if (current_tool_->accessAllKeys()) { // if yes, pass the key - current_tool_->processKeyEvent(event, panel); + flags = current_tool_->processKeyEvent(event, panel); } else { // if no, switch the tool setCurrentTool(tool); @@ -176,7 +177,11 @@ void ToolManager::handleChar(QKeyEvent * event, RenderPanel * panel) } else { // if the incoming key triggers no other tool, // just hand down the key event - current_tool_->processKeyEvent(event, panel); + flags = current_tool_->processKeyEvent(event, panel); + } + + if (flags & Tool::Finished) { + setCurrentTool(getDefaultTool()); } }