Overlapping images in Derma

I’m creating a custom inventory screen for my gamemode and I don’t want it to look like a regular Garry’s Mod menu so I am building it out of images(bad idea?). So I have one large background image that is just a “DImage” and I have a “DImageButton” in the corner for the close button. But the problem is that whenever I click on the background image the close button disappears. That is because the background image is brought to the front and overlaps the close button. Is there any way around this? Am I going about this the wrong way? This is my first Derma menu and I am very new to Lua.

You can override the **[Panel.Paint

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=Panel.Paint)** function on your Derma elements and draw them yourself with the [url=]surface library.

Yes, what maker said. I draw all my background with surface. Something like this:


how do you make it go away with a close button?


like that? I’ not sure exactly how I would do this. I have other things in my menu that use “surface.”
So how would I address just that specific one? also I had a grid that was part of the background image how would I make that how it was. Do I have to make a “DFrame”?

As far as I can tell, the close button isn’t drawn using the surface library, and is drawn before the Paint function is ever called.



Once the surface draw function is called, the set color, size, font name, w/e you called before that is drawn onto the surface. Setting the color again won’t overwrite/reset the past drawn objects, the new color will only show up in future objects that you will plan to draw.

An example of what you can do is set the color, draw a background object, set the color again, draw an inner object, then set the color to your background object and draw another inner object, making the illusion that there’s an outline of an object.