Skip to content

Commit

Permalink
Emit node-double-click event (#383)
Browse files Browse the repository at this point in the history
* Emit node-double-click event

* nit
  • Loading branch information
huchenlei authored Dec 20, 2024
1 parent 6165709 commit e442732
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/LGraphCanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2500,6 +2500,11 @@ export class LGraphCanvas {
node.onNodeTitleDblClick?.(e, pos, this)
}
node.onDblClick?.(e, pos, this)
this.emitEvent({
subType: "node-double-click",
originalEvent: e,
node,
})
this.processNodeDblClicked(node)
}

Expand Down
7 changes: 0 additions & 7 deletions src/litegraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,6 @@ export interface LinkReleaseContextExtended {

export interface LiteGraphCanvasEvent extends CustomEvent<CanvasEventDetail> {}

export interface LiteGraphCanvasGroupEvent
extends CustomEvent<{
subType: "group-double-click"
originalEvent: MouseEvent
group: LGraphGroup
}> {}

/** https://github.com/jagenjo/litegraph.js/blob/master/guides/README.md#lgraphnode */

export interface LGraphNodeConstructor<T extends LGraphNode = LGraphNode> {
Expand Down
6 changes: 6 additions & 0 deletions src/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export type CanvasEventDetail =
| DragggingCanvasEventDetail
| ReadOnlyEventDetail
| GroupDoubleClickEventDetail
| NodeDoubleClickEventDetail
| EmptyDoubleClickEventDetail
| ConnectingWidgetLinkEventDetail
| EmptyReleaseEventDetail
Expand Down Expand Up @@ -81,6 +82,11 @@ export interface GroupDoubleClickEventDetail extends OriginalEvent {
group: LGraphGroup
}

export interface NodeDoubleClickEventDetail extends OriginalEvent {
subType: "node-double-click"
node: LGraphNode
}

export interface DragggingCanvasEventDetail {
subType: "dragging-canvas"
draggingCanvas: boolean
Expand Down

0 comments on commit e442732

Please sign in to comment.