Skip to content

Commit 6e8dd97

Browse files
authored
Merge pull request #230 from RobTheFiveNine/bugfix/buttons-register-two-clicks
Fix widget buttons registering clicks twice
2 parents 4090718 + d0eedf7 commit 6e8dd97

7 files changed

Lines changed: 63 additions & 67 deletions

File tree

build/litegraph.core.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8855,16 +8855,15 @@ LGraphNode.prototype.executeAction = function(action)
88558855
//inside widget
88568856
switch (w.type) {
88578857
case "button":
8858-
if (event.type === "mousemove") {
8859-
break;
8860-
}
8861-
if (w.callback) {
8862-
setTimeout(function() {
8863-
w.callback(w, that, node, pos, event);
8864-
}, 20);
8865-
}
8866-
w.clicked = true;
8867-
this.dirty_canvas = true;
8858+
if (event.type === "mousedown") {
8859+
if (w.callback) {
8860+
setTimeout(function() {
8861+
w.callback(w, that, node, pos, event);
8862+
}, 20);
8863+
}
8864+
w.clicked = true;
8865+
this.dirty_canvas = true;
8866+
}
88688867
break;
88698868
case "slider":
88708869
var range = w.options.max - w.options.min;

build/litegraph.core.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/litegraph.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8855,16 +8855,15 @@ LGraphNode.prototype.executeAction = function(action)
88558855
//inside widget
88568856
switch (w.type) {
88578857
case "button":
8858-
if (event.type === "mousemove") {
8859-
break;
8860-
}
8861-
if (w.callback) {
8862-
setTimeout(function() {
8863-
w.callback(w, that, node, pos, event);
8864-
}, 20);
8865-
}
8866-
w.clicked = true;
8867-
this.dirty_canvas = true;
8858+
if (event.type === "mousedown") {
8859+
if (w.callback) {
8860+
setTimeout(function() {
8861+
w.callback(w, that, node, pos, event);
8862+
}, 20);
8863+
}
8864+
w.clicked = true;
8865+
this.dirty_canvas = true;
8866+
}
88688867
break;
88698868
case "slider":
88708869
var range = w.options.max - w.options.min;
@@ -14879,7 +14878,7 @@ if (typeof exports != "undefined") {
1487914878

1488014879
//Converter
1488114880
function Converter() {
14882-
this.addInput("in", "*");
14881+
this.addInput("in", "");
1488314882
this.addOutput("out");
1488414883
this.size = [80, 30];
1488514884
}
@@ -17749,7 +17748,7 @@ if (typeof exports != "undefined") {
1774917748
// Texture Webcam *****************************************
1775017749
function ImageWebcam() {
1775117750
this.addOutput("Webcam", "image");
17752-
this.properties = { facingMode: "user" };
17751+
this.properties = { filterFacingMode: false, facingMode: "user" };
1775317752
this.boxcolor = "black";
1775417753
this.frame = 0;
1775517754
}
@@ -17759,8 +17758,8 @@ if (typeof exports != "undefined") {
1775917758
ImageWebcam.is_webcam_open = false;
1776017759

1776117760
ImageWebcam.prototype.openStream = function() {
17762-
if (!navigator.getUserMedia) {
17763-
//console.log('getUserMedia() is not supported in your browser, use chrome and enable WebRTC from about://flags');
17761+
if (!navigator.mediaDevices.getUserMedia) {
17762+
console.log('getUserMedia() is not supported in your browser, use chrome and enable WebRTC from about://flags');
1776417763
return;
1776517764
}
1776617765

@@ -17769,7 +17768,7 @@ if (typeof exports != "undefined") {
1776917768
// Not showing vendor prefixes.
1777017769
var constraints = {
1777117770
audio: false,
17772-
video: { facingMode: this.properties.facingMode }
17771+
video: !this.properties.filterFacingMode ? true : { facingMode: this.properties.facingMode }
1777317772
};
1777417773
navigator.mediaDevices
1777517774
.getUserMedia(constraints)

0 commit comments

Comments
 (0)