Here is the code:
Code: Select all
void LuaGui::Build(char const *layout) {
// This loads a simple dialog with an "OK" and a "Cancel" button
// and two text fields.
window_ = CEGUI::WindowManager::getSingleton().loadWindowLayout(
(CEGUI::utf8*)layout);
BuildWidgetList(window_);
}
void LuaGui::BuildWidgetList(CEGUI::Window *window) {
if (window->getType() == "TaharezLook/Button") {
// I verified that this gets called, and the conn has a refcount
CEGUI::Event::Connection conn = window_->subscribeEvent(
CEGUI::PushButton::EventClicked,
CEGUI::Event::Subscriber(&LuaGui::HandleClicked, this));
connections_[window->getName()] = conn;
}
widgets_[window->getName()] = window;
for (size_t cnt = window->getChildCount(), i = 0; i < cnt; ++i) {
BuildWidgetList(window->getChildAtIdx(i));
}
}
bool LuaGui::HandleClicked(CEGUI::EventArgs const &e) {
// I never get here, even when clicking the buttons
if (stateMachine_ != 0) {
stateMachine_->Stimulate(static_cast<CEGUI::WindowEventArgs const &>(e).window->getName().c_str());
}
return true;
}