cancel
Showing results for 
Search instead for 
Did you mean: 

how to use the 'button is clicked' to show or hide the image ?

miker
Visitor

how to use the 'button is clicked' to show or hide the image ? who can provide the sample program to be reference .

 

 

miker_0-1740386272525.png

 

3 REPLIES 3
GaetanGodart
ST Employee

Hello @miker ,

 

You can use the method setVisible to manage the visibility of your image and you can use the isVisible method to know if it is currently visible or not.

Please find attached an example where clicking on a button toggle the visibility of an image.
Note that the code is directly inside the interaction as I do "execute C++ code" instead of "Call new virtual function".

 

I hope this helps!
If this post answers your question, I invite you to select it as "best answer".

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)
miker
Visitor

miker_0-1740389561236.png

whether use the 'hide widget' to execute this function ?if yes, could you have any sample program to be provided ?

The "Hide widget" action will only allow you to hide the image, not to set it back to visible.
Also, it doesn't allow you to use a condition like I did with "!isVisible(image1)".

So if you want to hide and unhide a widget with only interaction, you will need 2 buttons, one to hide the image and another one to show the widget.

Please find an example attached.

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)