bartbutenaers / node-red-contrib-ui-svg

A Node-RED widget node to show interactive SVG (vector graphics) in the dashboard
Apache License 2.0
93 stars 27 forks source link

Missing events in JS Tab-sheet (like e.g. the 'change' event) #79

Open krikkoo opened 3 years ago

krikkoo commented 3 years ago

Hi @bartbutenaers, As required, I'm reporting here a message and relevant info, discussed in the issue #76 but that it was not related to that topic.

I found, surfing on web at this link, that there are some Event Attributes that could be useful to add in the JS tab, for example onchange for text could be very useful. I really don't know if it is possible, here below what I have done.

Here below a list of available events for SVG elements, some of these are already in your wonderful node.

Schermata 2020-11-28 alle 23 31 08

What I'm asking, is it possible to add missing events (like e.g. the 'change' event) in the JS Tab-sheet? If you added the event change in the JS sheet that trigger when a text field change its value, we will be able to run some script that can do other actions.

Node-Red instance is hosted on a Raspberry pi 3.

Thank you for you infinite patient and to allow users like me to enjoy with SVG in Node Red..

Great job

Regards

bartbutenaers commented 3 years ago

Hi @krikkoo, Thanks for the very nice summary!

So I assume you want to have those events in both tabsheets:

I can see a use case when a user executes an action in the the SVG (which results in the update of e.g. a text), that you want to take action. But would be nice to have some example use cases, so other users can learn from your ideas...

When thinking about this, I have one doubt: suppose you have N dashboards open simultaneously.

  1. So the same SVG drawing is being displayed N times.
  2. Suppose an input message is being injected which causes a text being updated.
  3. Then on N dashboards a change event handler will be triggered.
  4. So N duplicate output messages will arrive in the Node-RED flow. And zero messages will be sfng when no SVG drawing is currently being displayed.

I imagine that this might be confusing, and causing overhead. But I might misinterpreting your use case incorrectly! Bart

bartbutenaers commented 3 years ago

So what I mean: all other events indicate a user action (click, hoover, touch,...) to which we want to respond. However I think e.g. change on an SVG "text" element can be caused by lots of things, but not directly by a user action. Because the SVG "text" element is not editable by a user, unlike a normal html text input field. So I 'think' we should handle your new events in a different way, to avoid duplicate messages and other weird behaviour. But I'm not sure at the moment...

bartbutenaers commented 3 years ago

@krikkoo , I have created a test version last night, and I 'think' your change-event becomes even more powerfull if we combine it with foreign objects in SVG. I have started a discussion about it on the Node-RED forum, and hopefully I get some feedback there... In that discussion you can find the command to install the test branch, an example flow and a demo movie. So would be nice if you could give me some feedback, whether this fits your needs. Bart

krikkoo commented 3 years ago

Hi @bartbutenaers, Sorry but I'm very overloaded at work and I didn't find time to check your posts. I'll check the open discussion on the Node-RED forum, I'll do some test and I'll give you my feedback soonest

Thank you very match for your support, you are the best one..

best regards

bartbutenaers commented 3 years ago

Hi @krikkoo , Would be nice if you could give me some feedback, because it would like to build a new release (containing features and fixes other users are waiting for ...). Thanks! Bart

krikkoo commented 3 years ago

Hi @bartbutenaers Sorry if I disappeared but it has been a very hard period at work and home too. I have done some test and as usual your new feature is working well. That would be really cool if the same event could be applied to the labels also, I know that this event is not available for labels but maybe you can do some magic. Anyway you can release this version. Thank you for you help

I wish you happy new year!!! Krikko

bartbutenaers commented 3 years ago

Hey @krikkoo, No problem. Here VERY busy also... But you need to refresh my memory, because I have done so many other things meanwhile. In which cases does the change event work well for you? Can you please pass me a test flow, because that would help me a LOT!!

Last week I wrote down another feature that I should implement in the near future: see here. That might be a solution for your request.

But when looking at my screenshot in the mutation observer issue, I see that I have added a "update" event. I'm not sure anymore what the difference would be with the change event...

Happy newyear for you too!!! Bart