Im trying to make my svg clickable in phone i try this in my web its working but in phone i cant make it work can please someone help me solve my problem i want when i click the part it will store the selected part to a database please check the attach oml
Hi @Benedict cruz,
First I would like to say there are no one way to make certain a solution, but I would make quite some changes.
1. SVG Image
Group each path and text tag corresponding to body part in a group tag, and give this tag an Id describing this body part. So when we click on the path or the text, they will trigger the OnClick event of the group.
Also, I prefer to apply the style using the tag name instead of adding a class to each tag, as it could save effort in case we apply any change.
I changed the default fill of the path to transparent, as it was none, so you would not be able to click on the body part, as the app will not be able to detect that you are on the part, as the interior will be empty. To solve this I set it to a transparent color.
Finally, We shall add the selected style as well in the style section.
2. Binding OnClick Event
I would suggest binding the OnClick event in the Initialized event of the InlineSVG widget instead of the screen OnReady event, to make sure that the svg image had been rendered.
In the Initialized event, use the widget Id to select all the groups selected in step 1, and add OnClick to them.
In the OnClick event toggle the selected class, and pass the Id of the group to an action to update the list of your selected items
3. Saving Selected Items
In the action called in the click event, add and remove the Id of the selected body part.
When you finish, you can use the selected Ids to save them in the database
Results
You can see that we have some body parts highlighted based on clicked parts.
Finally you can find oml files for a web and phone apps for this solution attached to this reply.
Regards,Mustafa.
great sample
Thanks @Shingo Lam
Super helpful thank you Sir For making a solution for my problem godbless you sir!! @Mustafa Emad Shaker
You are welcome @Benedict cruz