Skip to main content
Zui
Senior
May 22, 2019
Solved

How to move an object (image, button, whatever) foreground or background

  • May 22, 2019
  • 3 replies
  • 1390 views

Greetings

In my current project i need a way to change the whole project style, so for now i'm changing just the background. my default background is just a colored box, but if another style is selected i wanna set an image as background, and thats is done easily, but i can't figure out how to move the just created behind pre-existing objects. I saw that in the viewBase class the object order is just the order which they are created, no functions to set their order (as far as i know), so i can't create my image as background, because the viewbase class is called before my implemantation. A temporaly solution found was creating the image in the designer with no image set (or with .setVisible(false)), but i was hoping for a better solution.

Thanks for any suggestion.

Stefano

This topic has been closed for replies.
Best answer by Martin KJELDSEN

Hi @Zui​,

Sorry i missed this!

Let me show you how to manipulate the z-order programatically.

void swapBoxForImage()
{
 //remove all drawables
 remove(mybackgroundBox);
 remove(d1);
 remove(d2);
 
 add(myBackgroundImg);
 add(d1);
 add(d2);
}

3 replies

Martin KJELDSEN
Martin KJELDSENBest answer
Principal III
June 13, 2019

Hi @Zui​,

Sorry i missed this!

Let me show you how to manipulate the z-order programatically.

void swapBoxForImage()
{
 //remove all drawables
 remove(mybackgroundBox);
 remove(d1);
 remove(d2);
 
 add(myBackgroundImg);
 add(d1);
 add(d2);
}

Zui
ZuiAuthor
Senior
June 13, 2019

yeah, i figured that out by myself watching some touchGfx examples, but tnx anyway ;)

Martin KJELDSEN
Principal III
June 13, 2019

Okay, glad you could find it on your own :)