Jekteir
28-07-2007 00:59:15
I'm recursing through all the widgets within my guiSheet (default sheet) and disabling all those widgets which are not my "confirmExitWindow", or within that window. The idea is the same as a standard Windows 'on top of all others, holds focus'-style window. This seems to be working fine now (as you can see below, trying to disable a ListItem-style widget crashes the program with a bad pointer, so I avoid those types of widget; no idea where the crash happens; I assume it's because the disable code higher up does something inappropriate for that type of widget): when I pop my exit window up and run disableWidgets(), all widgets except for the 'Yes/No' dialog are disabled. They look disabled, too.
However, when I run enableWidgets() (assuming the user cancelled their decision to exit), while the functionality of all widgets is restored, the text at the top of menu lists (e.g. 'File' for the file menu: the text on that actual top bar), and also text within labels (and maybe other things, but that's all the widgets I have right now), are not made white again, but remain darkened.
Any idea how I could fix this? Feel free to use this code, or any of it you like, if you wanna create a similar 'always-on-top, holds-focus'-style toggle setting for widgets :) I'd be in favour. The try/catch statement, by the way, is just to establish the enum int value of any type that crashes on disable. I haven't tested that exceptions code, so I have no idea if it works ;)
Jek
However, when I run enableWidgets() (assuming the user cancelled their decision to exit), while the functionality of all widgets is restored, the text at the top of menu lists (e.g. 'File' for the file menu: the text on that actual top bar), and also text within labels (and maybe other things, but that's all the widgets I have right now), are not made white again, but remain darkened.
Any idea how I could fix this? Feel free to use this code, or any of it you like, if you wanna create a similar 'always-on-top, holds-focus'-style toggle setting for widgets :) I'd be in favour. The try/catch statement, by the way, is just to establish the enum int value of any type that crashes on disable. I haven't tested that exceptions code, so I have no idea if it works ;)
Jek
void WorldEditor::disableWidgets(QuickGUI::Widget* widgetPointer)
{
if (widgetPointer->getInstanceName() != "confirmExitWindow" && widgetPointer->getWidgetType() != QuickGUI::Widget::QGUI_TYPE_LISTITEM)
{
try
{
widgetPointer->disable();
}
catch (int e)
{
std::stringstream ss;
std::string str;
ss << int(widgetPointer->getWidgetType());
ss >> str;
Ogre::LogManager::getSingletonPtr()->logMessage("Problem with " + str);
}
}
if (widgetPointer->getInstanceName() != "confirmExitWindow")
{
std::vector<QuickGUI::Widget*> *childWidgets = widgetPointer->getChildWidgetList();
if (!childWidgets->empty())
{
for (std::vector<QuickGUI::Widget*>::iterator i = childWidgets->begin(); i < childWidgets->end(); i++)
{
disableWidgets(*i);
}
}
}
}
void WorldEditor::enableWidgets(QuickGUI::Widget* widgetPointer)
{
if (widgetPointer->getInstanceName() != "confirmExitWindow" && widgetPointer->getWidgetType() != QuickGUI::Widget::QGUI_TYPE_LISTITEM)
{
widgetPointer->enable();
}
if (widgetPointer->getInstanceName() != "confirmExitWindow")
{
std::vector<QuickGUI::Widget*> *childWidgets = widgetPointer->getChildWidgetList();
if (!childWidgets->empty())
{
for (std::vector<QuickGUI::Widget*>::iterator i = childWidgets->begin(); i < childWidgets->end(); i++)
{
enableWidgets(*i);
}
}
}
}