From dda5a1d19bfb858a8ebf9d27d79cc8e5089d6d73 Mon Sep 17 00:00:00 2001 From: codetypes Date: Thu, 24 Apr 2025 09:53:45 +0800 Subject: [PATCH] double-click to select and edit subtree --- src/components/graph.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/graph.ts b/src/components/graph.ts index cf5b460..849ffbc 100644 --- a/src/components/graph.ts +++ b/src/components/graph.ts @@ -98,6 +98,7 @@ export class Graph { this._graph.on(G6CanvasEvent.CLICK, this._onCanvasClick.bind(this)); this._graph.on(G6NodeEvent.CONTEXT_MENU, this._onContextMenu.bind(this)); this._graph.on(G6NodeEvent.CLICK, this._onClick.bind(this)); + this._graph.on(G6NodeEvent.DBLCLICK, this._onDblClick.bind(this)); this._graph.on(G6NodeEvent.DRAG_START, this._onDragStart.bind(this)); this._graph.on(G6NodeEvent.DRAG_END, this._onDragEnd.bind(this)); this._graph.on(G6NodeEvent.DRAG_ENTER, this._onDragEnter.bind(this)); @@ -562,6 +563,11 @@ export class Graph { this.selectNode(e.target.id); } + private _onDblClick(e: IG6PointerEvent) { + this.selectNode(e.target.id); + this.editSubtree(); + } + private _isDragState(state: string): boolean { return ( state === "dragsrc" || state === "dragup" || state === "dragdown" || state === "dragright"