Implement clickable badges (#8401)

Adds an `onClick` handler to LGraphBadge

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-8401-Implement-clickable-badges-2f76d73d365081b3b23fc1eaa3bc65b8)
by [Unito](https://www.unito.io)
This commit is contained in:
AustinMroz
2026-01-29 00:04:28 -08:00
committed by GitHub
parent 3866fe7eaa
commit 44baadd7ca
6 changed files with 34 additions and 3 deletions

View File

@@ -1,3 +1,5 @@
import { toValue } from 'vue'
import { LGraphNodeProperties } from '@/lib/litegraph/src/LGraphNodeProperties'
import {
calculateInputSlotPosFromSlot,
@@ -2084,7 +2086,13 @@ export class LGraphNode
* checks if a point is inside the shape of a node
*/
isPointInside(x: number, y: number): boolean {
return isInRect(x, y, this.boundingRect)
if (isInRect(x, y, this.boundingRect)) return true
for (const badge of this.badges.map(toValue).filter((b) => b.onClick)) {
if (isInRect(x - this.pos[0], y - this.pos[1], badge.boundingRect))
return true
}
return false
}
/**