Page 1 of 1

HandleClicked handler not getting called

Posted: Sat Mar 10, 2007 00:26
by some_name
I am loading a GUI layout, and then, for each widget that is a push button, I subscribe to HandleClicked. I have verified in the debugger that the subscription code is getting called. However, when clicking the buttons, the event handler does not get called.

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;
}

Posted: Sat Mar 10, 2007 00:27
by some_name
Nevermind. After posting this, I finally saw the underscore that made it not work. It often takes a second set of imagined eyes...