Create global function

In Thunkable X no global functions, but we can call them indirectly. The following illustrates one of the basic examples of how to call a function that is on the other screen.

Blocks for Screen1 (set timer loops = false)

%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5

Blocks for Screen2

%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5

An example can be viewed at the link

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

5 Likes

:heart: :+1:

Nice - I already wondered if this was possible but didn’t try it yet ^^

1 Like

from Alert Timer1 set Message

Should it be Alert1 rather than Timer1 here?

1 Like

Yes, as you need to specify the type of Alert. The fact that the list of props is dependent on the selected component type (not a coponent). We have for the component Alert property Message, while the Timer component is not. Therefore, as the component type, choose Alert.

Simply put, by choosing a suitable type, you can extend the functionality of existing components. Do you remember my example to change the font size in the Text Input? It uses a similar decision. I took the components that had this property Font Size and added it to the Text Input component that this property does not exist.

This method allows you to change the properties of some of the components, for which there are no blocks. Not necessarily to create blocks for all components. Enough to create many useful blocks for multiple components, and then apply them to the other. I wrote about this, but if you like this idea, then I ask you to recall Mark about it. Thunkable X can be a very interesting tool, but it depends entirely on the developer and some of us - members.

1 Like

Please note that my method can also work with the values ​​of properties for the components that are on the other screen. This can be used, for example, to pre-load or execute actions that previously could be done only in the block Open.