double-click to select and edit subtree

This commit is contained in:
codetypes committed 2025-04-24 09:53:45 +08:00
1 parent ef10851e64
commit dda5a1d19b
1 file changed
+6
+6
View File
@@ -98,6 +98,7 @@ export class Graph {
this._graph.on(G6CanvasEvent.CLICK, this._onCanvasClick.bind(this)); this._graph.on(G6CanvasEvent.CLICK, this._onCanvasClick.bind(this));
this._graph.on(G6NodeEvent.CONTEXT_MENU, this._onContextMenu.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.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_START, this._onDragStart.bind(this));
this._graph.on(G6NodeEvent.DRAG_END, this._onDragEnd.bind(this)); this._graph.on(G6NodeEvent.DRAG_END, this._onDragEnd.bind(this));
this._graph.on(G6NodeEvent.DRAG_ENTER, this._onDragEnter.bind(this)); this._graph.on(G6NodeEvent.DRAG_ENTER, this._onDragEnter.bind(this));
@@ -562,6 +563,11 @@ export class Graph {
this.selectNode(e.target.id); this.selectNode(e.target.id);
} }
private _onDblClick(e: IG6PointerEvent<G6Rect>) {
this.selectNode(e.target.id);
this.editSubtree();
}
private _isDragState(state: string): boolean { private _isDragState(state: string): boolean {
return ( return (
state === "dragsrc" || state === "dragup" || state === "dragdown" || state === "dragright" state === "dragsrc" || state === "dragup" || state === "dragdown" || state === "dragright"