[BugFix] Trigger IWidget.callback on widget drag (#514)

This commit is contained in:
Chenlei Hu
2025-02-10 14:37:16 -05:00
committed by GitHub
parent adff23bb84
commit f0eca030c4
4 changed files with 7 additions and 7 deletions

View File

@@ -2568,6 +2568,7 @@ export class LGraphCanvas implements ConnectionColorContext {
pointer.onDrag = eMove => widgetInstance.onDrag({
e: eMove,
node,
canvas: this,
})
} else {
if (widget.mouse) {

View File

@@ -96,6 +96,7 @@ export abstract class BaseWidget implements IBaseWidget {
onDrag(options: {
e: CanvasMouseEvent
node: LGraphNode
canvas: LGraphCanvas
}): void {}
/**

View File

@@ -146,8 +146,9 @@ export class NumberWidget extends BaseWidget implements INumericWidget {
override onDrag(options: {
e: CanvasMouseEvent
node: LGraphNode
canvas: LGraphCanvas
}) {
const { e, node } = options
const { e, node, canvas } = options
const width = this.width || node.width
const x = e.canvasX - node.pos[0]
const delta = x < 40
@@ -168,9 +169,7 @@ export class NumberWidget extends BaseWidget implements INumericWidget {
newValue = this.options.max
}
if (newValue !== this.value) {
this.value = newValue
return true
this.setValue(newValue, { e, node, canvas })
}
return false
}
}

View File

@@ -119,6 +119,7 @@ export class SliderWidget extends BaseWidget implements ISliderWidget {
override onDrag(options: {
e: CanvasMouseEvent
node: LGraphNode
canvas: LGraphCanvas
}) {
if (this.options.read_only) return false
@@ -131,9 +132,7 @@ export class SliderWidget extends BaseWidget implements ISliderWidget {
const newValue = this.options.min + (this.options.max - this.options.min) * slideFactor
if (newValue !== this.value) {
this.value = newValue
return true
this.setValue(newValue, options)
}
return false
}
}