mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-03 04:31:58 +00:00
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:
@@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user