added combo widget

This commit is contained in:
tamat
2020-02-04 15:13:32 +01:00
parent 469e3d964c
commit 5cef341c29
4 changed files with 788 additions and 698 deletions

View File

@@ -273,6 +273,47 @@
LiteGraph.registerNodeType("widget/number", WidgetNumber);
/* Combo ****************/
function WidgetCombo() {
this.addOutput("", "string");
this.addOutput("change", LiteGraph.EVENT);
this.size = [80, 60];
this.properties = { value: "A", values:"A;B;C" };
this.old_y = -1;
this.mouse_captured = false;
this._values = this.properties.values.split(";");
var that = this;
this.widgets_up = true;
this.widget = this.addWidget("combo","", this.properties.value, function(v){
that.properties.value = v;
that.triggerSlot(1, v);
}, { property: "value", values: this._values } );
}
WidgetCombo.title = "Combo";
WidgetCombo.desc = "Widget to select from a list";
WidgetCombo.prototype.onExecute = function() {
this.setOutputData( 0, this.properties.value );
};
WidgetCombo.prototype.onPropertyChanged = function(name, value) {
if(name == "values")
{
this._values = value.split(";");
this.widget.options.values = this._values;
}
else if(name == "value")
{
this.widget.value = value;
}
};
LiteGraph.registerNodeType("widget/combo", WidgetCombo);
/* Knob ****************/
function WidgetKnob() {