Page 1 of 1

[SOLVED, thanks] ignore events IGUIElements

Posted: Sat Oct 07, 2017 10:17 am
by realmsinthemists
Am trying to find a way for a nice debug overlay in my application. i.e. a log output and specialised data trackers.

Using a IGUIPanel (i.e. copied IGUIWindow and removed the captionbar and close button, registered in an own IGUIElementFactory) as layer over the entire screen it prevents any mouse down to be picked up which are underneath the panel. Bringing the panel to the back would kinda like kill the principle of an overlay. Even then still there is this problem of picking into the scene will be prevented.

Removing the panel and adding for instance the static texts to the environment root will have the same problem. Although the text should be in front of everything, the button at the back should be able to be pressed.

Is there a way to handle this while keeping the panel (IGUIWindow) at the front?

r,

Re: ignore events IGUIElements

Posted: Sat Oct 07, 2017 2:48 pm
by CuteAlien
Yeah, needs a little trick. You have to remove those elements from the usual guienvironment. To do that - first create them as usual. Then grab() the element. Then call remove() on it to remove it from the guienvironment. And after you draw the usual gui-elements with drawAll() you have to call draw() on your overlay elements. You can have a overlay top-element and calling draw() for that - it will then again draw() it's children. Oh - and remember to drop() those elements at the end of your application or you have a memory-leak now.

Example:

Code: Select all

 
IGUIButton * overlay = env->addButton(recti(10, 10, 200, 200), 0, -1, L"dumnmy");
overlay->grab();
overlay->remove();
 
while(device->run() && driver)
{
    driver->beginScene(true, true, SColor(0,200,200,200));
    env->drawAll();
    overlay->draw();
    driver->endScene();
}
 
overlay->drop();
 
edit: If you have children elements below the top overlay element you don't have to do the grab() remove() drop() stuff for them - you can just add them as child to the top overlay element.

Re: [SOLVED, thanks] ignore events IGUIElements

Posted: Tue Oct 10, 2017 12:52 pm
by MartinVee
That's a neat trick. Will need to remember this one!