Moving or copying UI element to another screen


#1

Is it possible to change which screen a UI element is on? We’ve tried copy and paste but it doesn’t seem to work with UI elements. Thanks!


#2

Are you just trying to create a screen that looks the same, or are you trying to get the same UI element to show up on multiple screens?

If you just want to create screens that look the same, but contain unique UI elements, create a single screen first, then use the “Duplicate” button on the screen’s property pane to make a copy of that screen and all elements on it.

If you’re trying to use the same unique element on multiple screens, we have an advanced undocumented command called setParent() that allows you to change the parent element of any UI element. In general I’d recommend sticking with the paradigm that each element lives on only one screen and either building screens with duplicate elements, or creating a single screen that shows/hides elements. If you’re interested in checking out setParent() you can check out this demo https://studio.code.org/projects/applab/g3tzP_JTJoonjIU6RBHuUw/view
The setTimeout() block is there to induce a delay before the element moves just to make it easier to see.


#3

Nice feature! I was asking about changing the parent screen in design mode, not at runtime, but that’s cool.

One situation where this has come up: a student makes a nicely styled button (say a “Home” button) and they want to copy it to the other screens too, but they’re already made those other screens. If they could duplicate the button, then move the copy to another screen, that would solve the problem.

Thanks again,
Alex


#4

Gotcha. There’s no way to do that currently, but I’ll log the request with our engineering team.