Setting a button's background picture to blank dynamically

I often use the Any Component blocks to loop through a series of buttons in a screen/row/column (Snap to Place interface) and hide some of them. Unfortunately, changing a button’s “visible” property affects the layout of components next to it (they move over to replace it) so I can’t use that. I want the layout to remain the same but the image itself to disappear. Think of a grid of faces with one missing/blank.

What I typically do is to loop through and change the background picture to “” (empty string). This had been working but I guess a change to the coding now prevents it.

This project demonstrates the issue. If you tap on the button, it should remove the image of the owl: Thunkable

Does anyone have a suggestion for something else to try until this can be fixed? I thought about making a .png with a single transparent (1% opacity) pixel and replacing the background picture with that but I haven’t tried it yet. Edit: That does work as a workaround (project: Thunkable).

These blocks work in a web preview but not in Thunkable Live on an iPhone:

Bug reported here: Setting button's picture to "" using Any Component blocks fails · Issue #1127 · thunkable/thunkable-issues · GitHub

1 Like

I tried both your projects and both works in Android. So this thing is again specific to iOS.

However, I created another project (copying yours) and placed the button inside a row and duplicated the row to create 3 rows (all set to relative size).

Now if you click on the middle one, I set visible property to false and other components don’t get effected as they are in separate containers.

https://x.thunkable.com/projectPage/622343d11aadef00124feec9

[Update]

I tried using the background picture but instead of assigning empty string “” or null I put a space in the text block and it worked. The image disappeared in Android.

Can you try it in iOS?

1 Like

Good idea to place the button in a row and hide the button but keep the row visible. That should work for me.

I can’t open your project by the way:

Oops! The project you are looking for was either deleted or may not be public.

1 Like

I’m sorry, I just looked for it and it seems it vanishes. I must have deleted it.

Here is a new one
https://x.thunkable.com/projectPage/6223d7ceb9166b0011284ea3

1 Like

That works, thank you!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.