Skip to content

Commit 4321054

Browse files
committed
Add double-click and navigate-up callbacks to NodeEditor
BaseNode gains a double-clicked(int) callback with timer-based detection (400ms window). NodeEditor forwards it as node-double-clicked and adds a navigate-up callback that fires on Escape when not creating a link.
1 parent 6b33fa9 commit 4321054

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

node-editor-building-blocks.slint

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ export component BaseNode inherits Rectangle {
339339
callback pin-drag-ended(int, length, length);
340340
callback pin-position-changed(/* pin-id */ int, /* node-id */ int, /* pin-type */ int, /* rel-x */ length, /* rel-y */ length);
341341
callback clicked(int, bool);
342+
callback double-clicked(int);
342343
callback drag-started(int, bool, length, length);
343344
callback drag-moved(int, length, length);
344345
callback drag-ended(int, length, length);
@@ -390,6 +391,13 @@ export component BaseNode inherits Rectangle {
390391
}
391392
}
392393

394+
// === Double-click detection ===
395+
property <bool> dbl-click-armed: false;
396+
dbl-click-timer := Timer {
397+
interval: 400ms;
398+
triggered => { root.dbl-click-armed = false; }
399+
}
400+
393401
// === Drag Handling ===
394402
TouchArea {
395403
property <bool> shift-held: false;
@@ -434,6 +442,14 @@ export component BaseNode inherits Rectangle {
434442
if was-selected-on-press && !shift-held {
435443
root.clicked(node-id, shift-held);
436444
}
445+
// Double-click detection
446+
if root.dbl-click-armed {
447+
root.double-clicked(node-id);
448+
root.dbl-click-armed = false;
449+
} else {
450+
root.dbl-click-armed = true;
451+
dbl-click-timer.restart();
452+
}
437453
}
438454
}
439455
}

node-editor.slint

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ export component NodeEditor {
222222
callback delete-selected();
223223
callback add-node-requested();
224224
callback context-menu-requested();
225+
callback node-double-clicked(/* node-id */ int);
226+
callback navigate-up();
225227
callback node-drag-started(/* node-id */ int);
226228
callback node-drag-ended(/* delta-x */ float, /* delta-y */ float);
227229

@@ -645,6 +647,8 @@ export component NodeEditor {
645647
} else if event.text == Key.Escape {
646648
if root.internal-is-creating-link {
647649
root.cancel-link-creation();
650+
} else {
651+
root.navigate-up();
648652
}
649653
accept
650654
} else if event.modifiers.control && (event.text == "n" || event.text == "N") {

0 commit comments

Comments
 (0)