Update-problem

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

Loke
Just popping in
Just popping in
Posts: 2
Joined: Fri Apr 28, 2006 12:33

Update-problem

Postby Loke » Fri Apr 28, 2006 13:36

This must be really simple, but I just can't get it to work. I want to create a light using a button and this works. When the new light is created it should appear in the "listbox" but it doesn't. If I where to destroy the lightWindow and then create it again, the text in the listbox would be there and I can select it and all.
Yes I know I am missing something easy, but I need to be able to update the listbox without destroy/create the lightWindow. Below is the code.

Code: Select all

    CEGUI::Window* editorWindow = CEGUI::WindowManager::getSingleton().getWindow((CEGUI::utf8*)"RootWindow");

   CEGUI::FrameWindow* lightWindow = static_cast<CEGUI::FrameWindow*>(CEGUI::WindowManager::getSingleton().createWindow(
      (CEGUI::utf8*)"TaharezLook/FrameWindow", (CEGUI::utf8*)"Light/LightWindow"));
   lightWindow->setSize(CEGUI::Absolute, CEGUI::Size(250, 260));
   lightWindow->setPosition(CEGUI::Absolute, CEGUI::Point(270, 36));
    lightWindow->setText((CEGUI::utf8*)"Light");
   editorWindow->addChildWindow(lightWindow);

   CEGUI::ListboxTextItem* listboxTextItem;

   CEGUI::Listbox* listbox = static_cast<CEGUI::Listbox*>(CEGUI::WindowManager::getSingleton().createWindow(
      (CEGUI::utf8*)"TaharezLook/Listbox", (CEGUI::utf8*)"Light/Listbox"));

   int numberOfObjects = static_cast<int>(m_level->m_staticObjects.size());
   for (int i=0 ; i<8 ; ++i)
   {
      if (m_lightEmitter[i]->IsActive() == true)
      {
         std::stringstream combined;
         combined << "Light" << i;
         listboxTextItem = new CEGUI::ListboxTextItem(combined.str());
         listboxTextItem->setText(combined.str());
         listboxTextItem->setSelected(false);
         listbox->addItem(listboxTextItem);
      }
   }
   for (int i=0 ; i<8 ; ++i)
   {
      if (m_lightEmitter[i]->IsActive() == true)
      {
            listboxTextItem->setSelected(true);
         m_selectedLight = i;
         break;
      }
   }
   listbox->setSize(CEGUI::Absolute, CEGUI::Size(60, 140));
   listbox->setPosition(CEGUI::Absolute, CEGUI::Point(10, 36));
   listbox->setFont("Tahoma-8");
   listbox->setShowHorzScrollbar(true);
   listbox->setShowVertScrollbar(true);
   lightWindow->addChildWindow(listbox);

   if (static_cast<int>(listbox->getItemCount()) > 0)
   {
      for (int i=0 ; i<static_cast<int>(listbox->getItemCount()) ; ++i)
      {
         CEGUI::colour grey(0.4, 0.4, 0.4, 0.5);
         listbox->getListboxItemFromIndex(i)->setSelectionColours(grey, grey, grey, grey);
         listbox->getListboxItemFromIndex(i)->setSelectionBrushImage("TaharezLook", "ListboxSelectionBrush");
      }
   }

   listbox->subscribeEvent(CEGUI::Listbox::EventSelectionChanged, CEGUI::Event::Subscriber(&EditorApplication::ActionLightChangeSelected, this));

   CEGUI::Window* createNewLight = CEGUI::WindowManager::getSingleton().createWindow(
      (CEGUI::utf8*)"TaharezLook/Button", (CEGUI::utf8*)"Light/CreateNewLight");
   createNewLight->setSize(CEGUI::Absolute, CEGUI::Size(165, 15));
   createNewLight->setPosition(CEGUI::Absolute, CEGUI::Point(75, 36));
   createNewLight->setText("Create new light");
   createNewLight->setFont("Tahoma-8");
   lightWindow->addChildWindow(createNewLight);
   createNewLight->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&EditorApplication::ActionCreateNewLightOk, this));


Loke
Just popping in
Just popping in
Posts: 2
Joined: Fri Apr 28, 2006 12:33

Postby Loke » Fri Apr 28, 2006 15:17

Gha.. I knew it was easy, still it took me 5 hours. Anyway, I've solved it now.

User avatar
jacmoe
Just can't stay away
Just can't stay away
Posts: 136
Joined: Sun Apr 03, 2005 14:18
Location: Holbaek, Denmark
Contact:

Postby jacmoe » Fri Apr 28, 2006 15:23

It would be of help to know what solved it - otherwise this poor topic will be kept hanging here without resolution :)


Return to “Help”

Who is online

Users browsing this forum: No registered users and 28 guests