This is probably simple, but I cannot figure this one out. I’ve been working days and long hours on this app and I am stumped trying to figure out how to mimic a button. For example: on one screen I have a create button which loads a layout. On that layout I have created another button to mimic the response of the create button. I cannot figure out how to tie these two together.
I don’t understand. The create button loads a layout, presumably by creating or cloning components, correct? And if you need another create button why not just use an actual button? Why do you need to mimic a button? Are you asking how to call a set of blocks (aka a function) from a different screen?
Yes so basically when create button is clicked it opens a layout which acts as a second screen and covers the main page. I then added a regenerate button , which will need to mimic the create button to generate another image.
Here’s a video to help explain a little better.
Does the create button show a Layout component? Because you can’t open a Layout component in Thunkable.
Why are you wanting to create an image? Wouldn’t the Create button always show a Layout? Why would it create/show an image?
I still feel like there’s a lot you’re not explaining. Do you have an example of this from another app/video/etc.?
Can you share a link to your project? It might make more sense to me if I can see your set up.
Removed Link*
Okay so go to stable diffusion, type anything in the prompt then hit the create button. You’ll see how I have a layer that pops up over the screen which will have a few buttons on the bottom. The generate button is the one I need to mimic the create button to regenerate the image.
Crap I thought with the app being private, you wouldn’t be able to see the code blocks.
Any thoughts?
If you want to share the link via private message, you can. Otherwise, I guess I’d need screenshots to understand this fully.
I asked about a function and it sounds like that’s what you’re describing. In other words, you have a set of blocks that trigger when you click the Create button. And then you want a different button in your overlayed layout that does the same thing as the Create button? If so, are those two buttons on different Thunkable screens or the same screen?
That’s exactly what I am trying to do. Yes both buttons are on the same screen.
Okay… so just create a function with the blocks you want for the Create button to trigger. And then in your second (“mimic”) button, call the function again.
Good Morning,
This would be my first time creating a function, I’ve tried multiple ways to see if I could get that trigger function to work but I’m pretty much lost at this point lol.
You said that you have blocks for a Create button that loads a layout. When you post a screenshot, you should be posting those blocks.
But then, move those blocks into a function. The default name for a function is “do something” but you should rename that. So your function could be called something like “Create layout”. Do not use the “do something and return block” which returns a value from the function. Just use the standard “do something” function block.
Then call the “Create layout” button from your “When Button Create Click” event block and see if that works as you expect it to.
Ughh I got it. I’m so mad at how easy that was! Thanks again your a great help!
Can you do the same for another screen or just items on the same screen?
Unfortunately, functions are not “global” so they are limited to a single screen. Thunkable needs to be a little more flexible and that’s one way it could be improved. That feature request has been made in the past but it wouldn’t hurt to make it again at Feature Requests - Community
There are some suggestions for workarounds here: Creating a function usable across screens
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.