SFML community forums

Help => Graphics => Topic started by: Chiggy_Playz on April 20, 2019, 05:42:31 pm

Title: Disable click through overlapping shapes?
Post by: Chiggy_Playz on April 20, 2019, 05:42:31 pm
I am really close to building my project but I am encountering one simple problem. I have a rectangle on which I have use the GetGlobalBounds to check if mouse clicks on it. Now I am drawing over another Rectangle over that rectangle and using GetGlobalBounds on the overlapping Rectangle. Now when i click on the overlapping one, the command for the original Rectangle is executed instead of the one that is overlapping. How can I prevent this?
Title: Re: Disable click through overlapping shapes?
Post by: eXpl0it3r on April 20, 2019, 11:45:31 pm
The events don't know of your render order, as such, you'll have to introduce your own depth/z-ordering.
That way your event processing would start at the upper most layer, where you then can also mark the event consumed and don't let is pass down to lower levels.
You can also make this simpler, but in the end, you'll have to somehow track what is at which depth.