Double click, and right click, on an SVG element

Started by Phil R., November 10, 2020, 12:50:32 PM

Previous topic - Next topic

Phil R.

Hi,

Can we configure an SVG element so that when we right click on it the menu that is displayed is the same as for a normal form element i.e. the actions with contextMenu="yes".

Also, how do we detect double click on an SVG element, to allow us to trigger an action e.g. edit the element in question.

Thanks,

Phil

Sebastien F.

Hello,

Are you implementing your own WEBCOMPONENT with SVG inside HTML, or do you use the FGLSVGCANVAS solution?

Seems that double-click events can be detected with SVG onclick event, by check the evt.detail content for number of clicks.
As basis, see FGLDIR/webcomponents/fglsvgcanvas/fglsvgcanvas.html (it implements simple mouse clicks).

For right-mouse clicks, I cant tell.

All of this needs further investigation.

=> Please open a support case.

Seb

Phil R.

Hi Seb,

We're using FGLSVGCANVAS, with that webcomponent in an existing form.

Thanks for the tip re the double-click.

Regards,

Phil

Sebastien F.

Ok if you are using FGLSVGCANVAS then it could be enhanced to support double clicks...
As I wrote please contact your support for the request.
Seb

Sebastien F.

Phil,

I have started to look at this in our FGLSVGCANVAS solution...

It appears that SVG onclick reacts on double click, and that seems to work with the current FGLSVGCANVAS code.

What is missing is some additional information in the field value, to distinguish simple clicks from double-clicks (event.detail)

We will work on this.

But if you only want to react on double-click, just give it a try (same ON ACTION will be fired) => click or double-click is the same for now.

Reacting on right-click is another story, this depends on the web content viewer / browser...

Seb

Sebastien F.

In fact, with FGLSVGCANVAS:

Each click will fire an action without any timeout/delay, so when user double-clicks on an SVG element, you get twice the action in the dialog code.

In the FGLDIR/demo/webcomponents/svgbasics demo, add a display below ON ACTION item_selection to see how it reacts...

So you can't make a diff between a regular click or double-click.

=> Must review FGLSVGCANVAS to properly support double clicks => WCG-152

Seb

Phil R.

Coincidentally, we do already check in ON ACTION item_selection to see when that action was last triggered, and which element it was. If it is the same element, and less than a second ago, we assume a double click. but it's all our own code, and it doesn't do the trick 100%.

So yes, an enhancement to FGLSVGCANVAS would be wonderful.

Thanks Seb!

Sebastien F.

Hello Phil,
Please if not done yet open a support request so we can properly track this.
Seb

Phil R.