54
Views
2
Comments
Solved
How to copy a Container's text info when tapped on a mobile screen?
Question
Application Type
Mobile

Hi there, 


I am trying to create the logic so I can copy the text inside the container(to my mobile phone keyboard) whenever I tap any part of the container.

So, what I did is :

1- In the container Event property I chose onclick

2- Created a new client action to be the handler 

3- In the client action, I created a local var "TextToCopy" of type text

4- I dragged an assign and typed TextToCopy (variable)= "ContainerName.TextName"(Value)

5- Then dragged a JS node : 

window.navigator.clipboard.writeText(TextToCopy);


when I test it, the error that appears says "TextToCopy " is not defined ( I tried switching the local var position to belong to the screen and not the client action(handler) but the same error persists.


Any way to solve this or any way to redo everything with a simpler solution.


Best regards,

Azhar

2024-03-27 13-27-06
Azhar Bondi
Solution

Since I also needed to copy only the number from the whole container I used this code and it works perfectly

2022-05-02 13-50-49
Paulo Ritto

Hi @Azhar Bondi

did you pass the textToCopy variable to the JS node as an input parameter?

Like this:
I just tried it and it works for me. I think your mistake might be that you are trying to use the textToCopy variable directly instead of passing it as input parameter to the JS node. Keep in mind that inside a JS node you are in a specific scope and you need to pass your variables to this scope, otherwise they won't be recognized.

Cheers,

Paulo

2024-03-27 13-27-06
Azhar Bondi
Solution

Since I also needed to copy only the number from the whole container I used this code and it works perfectly

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.