(null)
const spaceDown = ref(false)
+/** Space pressed and let go quickly, without moving the view: opens the search box at the mouse. */
+let spaceTap: { at: number } | null = null
let lastClick = { id: '', t: 0 }
function isDoubleClick(id: string) {
@@ -446,6 +448,7 @@ function onPointerDown(e: PointerEvent) {
const w = toWorld(e)
const v = view.value
if (e.button === 1 || e.button === 2 || (e.button === 0 && spaceDown.value)) {
+ spaceTap = null
menu.value = null
drag.value = { kind: 'pan', sx: e.clientX, sy: e.clientY, vx: v.x, vy: v.y, menu: e.button === 2 ? { target: e.target as Element, at: w } : undefined }
root.value!.setPointerCapture(e.pointerId)
@@ -1023,6 +1026,7 @@ function onKey(e: KeyboardEvent) {
nudge(dx * step, dy * step)
} else if (e.key === ' ') {
e.preventDefault()
+ if (!e.repeat) spaceTap = { at: performance.now() }
spaceDown.value = true
} else if (e.key === 'Enter' && ed.selection.value.length === 1) {
const n = nodeMap.value.get(ed.selection.value[0]!)
@@ -1035,7 +1039,12 @@ function onKey(e: KeyboardEvent) {
}
function onKeyUp(e: KeyboardEvent) {
- if (e.key === ' ') spaceDown.value = false
+ if (e.key === ' ') {
+ spaceDown.value = false
+ // A tap, not a hold for moving the view: the search box with recent parts and actions.
+ if (spaceTap && performance.now() - spaceTap.at < 350 && !quick.value) openQuickAdd()
+ spaceTap = null
+ }
const key = e.key.toLowerCase()
for (const n of def.value.nodes) if (n.kind === 'button' && n.key === key) ed.press(n, false)
for (const [n, r] of boundRows(key)) if (r.type === 'button') ed.pressRow(n, r, false)
@@ -1581,7 +1590,7 @@ defineExpose({ fit, zoomAt })
-
+
diff --git a/app/components/editor/Help.vue b/app/components/editor/Help.vue
index f4e9560..a0a14d4 100644
--- a/app/components/editor/Help.vue
+++ b/app/components/editor/Help.vue
@@ -37,8 +37,8 @@ const SHORTCUTS: [string, string][] = [
['Alt + click an input pin', 'Inverts it (a bubble); counted honestly as one NAND'],
['Send signal / Use signal', 'Name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire'],
['Ctrl+F', 'Find a part, signal or component in every circuit, and where a component is used'],
- ['Shift+A or Ctrl+K', 'Add a part at the mouse: type a few letters, arrows to choose, Enter to place'],
- ['/', 'The same: find a part by name and place it'],
+ ['Space (tap)', 'Search at the mouse: recent parts and actions like a new component; type a few letters, arrows to choose, Enter to take it'],
+ ['/, Shift+A or Ctrl+K', 'The same search box'],
['Ctrl+P', 'Print the circuit as a sheet with a title block, or save it as PDF'],
['Select switches or buttons, Combine', 'One input panel (all rows can become buttons); lamps or output pins combine into an output panel'],
['Select panels, Merge', 'One panel with all their rows; inside a component input panel rows are inputs, output panel rows outputs'],
diff --git a/app/components/editor/QuickAdd.vue b/app/components/editor/QuickAdd.vue
index 835996c..3290674 100644
--- a/app/components/editor/QuickAdd.vue
+++ b/app/components/editor/QuickAdd.vue
@@ -1,24 +1,107 @@