From 3f95905578ad14abe21b517ad25c9986c80a67f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jendrik=20J=C3=A4ger?= Date: Thu, 31 Aug 2023 19:14:13 +0200 Subject: [PATCH] Add capability to send payload on mouse down or mouse up --- button-group.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/button-group.js b/button-group.js index d764dfa..e354d43 100644 --- a/button-group.js +++ b/button-group.js @@ -15,7 +15,7 @@ module.exports = function (RED) { var heightPx = config.buttonheight * sizes.sy - sizes.gy; var html = `
- {{button.label}} + {{button.label}}
`; var done = ui.addWidget({ @@ -45,8 +45,22 @@ module.exports = function (RED) { $scope.buttonClick = function (e) { e.preventDefault(); var buttonId = e.target.id; - if ($scope.msg.buttons[buttonId].payload) { - $scope.send({ "payload": $scope.msg.buttons[buttonId].payload }); + if ($scope.msg.buttons[buttonId].click) { + $scope.send($scope.msg.buttons[buttonId].click); + } + }; + $scope.buttonDown = function (e) { + e.preventDefault(); + var buttonId = e.target.id; + if ($scope.msg.buttons[buttonId].down) { + $scope.send($scope.msg.buttons[buttonId].down); + } + }; + $scope.buttonUp = function (e) { + e.preventDefault(); + var buttonId = e.target.id; + if ($scope.msg.buttons[buttonId].up) { + $scope.send($scope.msg.buttons[buttonId].up); } }; }