My problem is very simple.
I write popup windows,and close with the X button in the corner.
I so far always write new function to all windows.
e.g.:
If two window:
Code: Select all
//...
PopupW1->subscribeEvent(FrameWindow::EventCloseClicked, Event::Subscriber(&EventButtonDown::PopupW1, EventDown));
//...
bool EventButtonDown::PopupW1(const CEGUI::EventArgs& /*e*/)
{
CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
wmgr.destroyWindow(PopupW1);
return true;
}
//...
PopupW2->subscribeEvent(FrameWindow::EventCloseClicked, Event::Subscriber(&EventButtonDown::PopupW2, EventDown));
//...
bool EventButtonDown::PopupW2(const CEGUI::EventArgs& /*e*/)
{
CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
wmgr.destroyWindow(PopupW2);
return true;
}
If ten window:
Code: Select all
//...
PopupW1->subscribeEvent(FrameWindow::EventCloseClicked, Event::Subscriber(&EventButtonDown::PopupW1, EventDown));
//...
bool EventButtonDown::PopupW1(const CEGUI::EventArgs& /*e*/)
{
CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
wmgr.destroyWindow(PopupW1);
return true;
}
//...
PopupW2->subscribeEvent(FrameWindow::EventCloseClicked, Event::Subscriber(&EventButtonDown::PopupW2, EventDown));
//...
bool EventButtonDown::PopupW2(const CEGUI::EventArgs& /*e*/)
{
CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
wmgr.destroyWindow(PopupW2);
return true;
}
//...
PopupW3->subscribeEvent(FrameWindow::EventCloseClicked, Event::Subscriber(&EventButtonDown::PopupW3, EventDown));
//...
bool EventButtonDown::PopupW3(const CEGUI::EventArgs& /*e*/)
{
CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
wmgr.destroyWindow(PopupW2);
return true;
}
//...
PopupW4->subscribeEvent(FrameWindow::EventCloseClicked, Event::Subscriber(&EventButtonDown::PopupW4, EventDown));
//...
bool EventButtonDown::PopupW4(const CEGUI::EventArgs& /*e*/)
{
CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
wmgr.destroyWindow(PopupW2);
return true;
}
//And the other to 6 ...
It's very difficult that each window plus function in my code.
Is there a simpler way,that close windows?