Repeat the last drawing or placing command with Enter

Enter on a folio runs the last drawing or placing command again, as it
does in SolidWorks: the last tool from the add-item family (text, line,
rectangle, terminal strip plan...) or the last element placed, however
it was placed -- dragged, double-clicked, picked, or from the shortcut
bar.

Enter is handled in DiagramView::keyPressEvent, not bound as a shortcut,
so it keeps working everywhere else: search fields, the collection
tree, dialogs. On the folio it is left alone while a tool is running or
an item has the focus (a text being edited), and with any modifier held.

The same command is in Édition, named after what it will do --
"Répéter : Ajouter une ligne", "Répéter : insérer « Diode »" -- and
registered with ShortcutManager (diagrameditor.repeat_last_command, no
default key), so it can be bound or put on the shortcut bar.

Discussion #1033.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G2d2Zi8BfrYRPX88zhaoFG
(cherry picked from commit 1e06ce97961ee18734ddaaa9b72b0303a169b9b2)
This commit is contained in:
ispyisail
2026-09-26 13:29:16 +12:00
parent b80d6e7cd3
commit 329831d986
3 changed files with 73 additions and 0 deletions
+12
View File
@@ -963,6 +963,18 @@ void DiagramView::keyPressEvent(QKeyEvent *e)
focusNextChild();
}
return;
case Qt::Key_Return:
case Qt::Key_Enter:
//Repeat the last drawing or placing command, as SolidWorks
//does. Not while a tool is running or a text has the focus:
//both use Enter themselves.
if (e->modifiers() == Qt::NoModifier
&& !m_diagram->eventInterfaceIsRunning()
&& !m_diagram->focusItem()
&& diagramEditor()->repeatLastCommand()) {
return;
}
break;
case Qt::Key_PageUp:
current_project->changeTabUp();
return;