Skip to content

Commit 352ef50

Browse files
AustinMrozsnomiao
authored andcommitted
Improve click regions for widget interaction (#5253)
1 parent 9bed2cc commit 352ef50

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/lib/litegraph/src/LGraphNode.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2136,10 +2136,22 @@ export class LGraphNode
21362136
widget.computeSize?.(nodeWidth)[1] ??
21372137
LiteGraph.NODE_WIDGET_HEIGHT
21382138

2139+
const maybeDOMWidget = widget as { margin?: number }
2140+
const mtop = maybeDOMWidget.margin ?? -2
2141+
const mbot = maybeDOMWidget.margin ?? 2
2142+
const mx = maybeDOMWidget.margin ?? 6
2143+
21392144
const w = widget.width || nodeWidth
21402145
if (
21412146
widget.last_y !== undefined &&
2142-
isInRectangle(x, y, 6, widget.last_y, w - 12, h)
2147+
isInRectangle(
2148+
x,
2149+
y,
2150+
mx,
2151+
widget.last_y + mtop,
2152+
w - 2 * mx,
2153+
h - mtop - mbot
2154+
)
21432155
) {
21442156
return widget
21452157
}

0 commit comments

Comments
 (0)