I need support with variables for many buttons

Hello.

I have a screen with a list of buttons: 60… I know, it is a lot.

The screen looks like this:


It is because I created a set of actions for each button: if button 1 clicks, then do that, if button 2 clicks… if button 3…

The actions for each button looks like this:
Screenshot%20at%20Jun%2018%2019-05-22
So, for each button should be disabled and enabled some actions, specific for each one, never repeated.

The problem it is that as I try to work with the page in blocks area, for 60 buttons with so many info each one, the page move very slowly and the process take to much (!) time.

Could somebody teach / show me how to create a variable in order to have a list: if button 1 clicks then action 1, if button 2 clicks then action 2, if button 3 clicks then action 3…

Thank you very much.

Ionut,

We are currently working on some features that should make the sort of thing that you are doing significantly easier and with many fewer blocks. In the meantime, could you create a share link to your project so that we have a better idea of what, exactly, you are doing?

-Mark

1 Like

Mamma mia! How could you do it?!

When working in Thunkable X, such problems are solved using a list of lists. Each list item has a list of states:

0,0,1,0
1,1,0,1
0,0,0,0

where 0 - false, 1 - true

When choosing an element from the list, these states should be considered in the corresponding variables and the variables should be assigned to the necessary blocks.

2 Likes

Thank you.
I will prepare a link.

Thank you for reply.

I need a list with a specific custom look and feel and as I know for the moment the lists are not changeable for look and feel (fonts, backgrounds, colors).
So I have done it only with buttons, each button with a custom image.
But it is very hard to be used or changed for the entire screen.

I have no idea how to create a simple if then function for clicks or in general.
Because if I can do that, then I may assign this function related to text or images…

One thing you can do is regrouping the activities that are common.
Given that “back_to_home” is probably generic and might be required for every button click, perhaps you should put this, along with all the other blocks that apply to all cases, in a procedure that is called by each button click. That procedure could receive an index that identifies the click as coming from a specific row or column of the button (I presume that “Row_lista” possibly implies there are “Row_listb” and “Row_listc” as well), so something like this could help reduce the block count:

In this example, Button2 calls the “button_process” with the index row 1 column 2. In turn, the “button_process” would perform all the settings that are unique to the row 1 in a specific block, and skip those meant for row 2 (and following). Likewise, a specific processing applies for each column, if needed.
For processing that apply to all, that would be put in the procedure just before the first “if” block, so that each call would do it.
For the processing that are truly unique, never applying to more than one button, you keep them in the button click block, just before calling the button processing procedure.

By the way, if your issue is only about scrolling around, and that your blocks are pretty much defined and in no need of frequent editing, you can collapse them (right click on the block, “Collapse Block”). This will show them as a single line of sort (which can be re-expanded with right click “Expand Block”). In their collapsed form, you can pack them a lot tighter on the screen, reducing the need for scrolling.

(And 60 buttons is not really that much. One of my app is a scientific unit calculator, and the main page has about that many buttons shown, several of which have dual SHIFT functions, plus a few dozen that pop up in special circumstances; and several others in other screens. If someone was to make a musical keyboard synth app, 60 buttons would be considered a low count… And yes, it does take time to scroll around, with over 6000 blocks in one screen. You learn to cope by keeping everything tidy so that you know in which direction to scroll next)

3 Likes

Thank you for your answer. For the time and attention
.
Yes, I know it could be more than 60.
My intention was to check with the community an alternative, not only for this, but for other projects.

I was sure that there is a function or a way that could make this easier or smarter. So, after more than a week, without a clear solution, I said ok, let see how this should be done.

Now I understand that for the moment there are many creative ways and in the future may be easier.

//

Thanks again to each of you!

Hi,

Your assumption is true about the possibility of simplifying similar structures. To do this, you must save the data in the properties of the button, for example, in the height property of the button you can save a list of parameters.

Run the project without viewing its blocks and tell me how many “If” blocks are used in it? And then look at the blocks.

https://x.thunkable.com/projects/5d1c7797291768743608ba92/project/properties/designer/

1 Like

Thank you.

I have done some tests over 2 weeks.
The idea, also as it is in your project it is great and douable…
But if there are 67 buttons and more than one function, the block screen needs 29 seconds for any type of response.
So, in the end I have decided to create a list, without any customization and a new screen for each button: 67 identical screens.

But, for the moment it is ok.
I see that the list of next updates includes transformation also for the list component.

Thank you.