Skip to content

Commit

Permalink
Handle Tool::Finished returned by processKeyEvent (#1257)
Browse files Browse the repository at this point in the history
  • Loading branch information
roncapat authored Aug 21, 2024
1 parent a72ef90 commit 37cf805
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions rviz_common/src/rviz_common/tool_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand All @@ -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());
}
}

Expand Down

0 comments on commit 37cf805

Please sign in to comment.