Page 1 of 1

Console with MultiLineEditbox or ListBox?

Posted: Wed Nov 03, 2010 17:43
by VitaliBR
I searched about and found this:
viewtopic.php?f=10&t=4358

But I have a problem,
using MultiLineEditbox:

Code: Select all

   CEGUI::Editbox* input =  static_cast<CEGUI::Editbox*>(CEGUI::WindowManager::getSingletonPtr()->getWindow("root/Console/input"));
   input->subscribeEvent(CEGUI::Editbox::EventTextAccepted, CEGUI::Event::Subscriber(&MenuState::CEGUI_onTextAccepted, this));

bool MenuState::CEGUI_onTextAccepted(const CEGUI::EventArgs &e)
{
   // Our text has been accepted by either deactivating it or pressing tab or enter.
   CEGUI::Editbox * editBox = static_cast<CEGUI::Editbox*>(CEGUI::WindowManager::getSingletonPtr()->getWindow("root/Console/input"));
   CEGUI::MultiLineEditbox * multiLineEditbox = static_cast<CEGUI::MultiLineEditbox*>(CEGUI::WindowManager::getSingletonPtr()->getWindow("root/Console/text_info"));

   multiLineEditbox->setText(editBox->getText());
   return true;
}


It's working perfectly :)

But when I try to use ListBox does not work (the string does not appear in the ListBox):

Code: Select all

   CEGUI::Editbox* input =  static_cast<CEGUI::Editbox*>(CEGUI::WindowManager::getSingletonPtr()->getWindow("root/Console/input"));
   input->subscribeEvent(CEGUI::Editbox::EventTextAccepted, CEGUI::Event::Subscriber(&MenuState::CEGUI_onTextAccepted, this));

bool MenuState::CEGUI_onTextAccepted(const CEGUI::EventArgs &e)
{
   // Our text has been accepted by either deactivating it or pressing tab or enter.
   CEGUI::Editbox * editBox = static_cast<CEGUI::Editbox*>(CEGUI::WindowManager::getSingletonPtr()->getWindow("root/Console/input"));
   CEGUI::Listbox * text_info = static_cast<CEGUI::Listbox*>(CEGUI::WindowManager::getSingletonPtr()->getWindow("root/Console/text_info"));

   text_info->setText(editBox->getText());
   return true;
}


Why? :?

Re: Console with MultiLineEditbox or ListBox?

Posted: Wed Nov 03, 2010 20:00
by Jamarr
You can already find the answer to this question by 1) Reviewing the samples (CEGUI\Samples folder) provided with the SDK or 2) searching the forum, wiki, and google or 3) reviewing the API. I know this is the Beginners Help forum, but please, at least attempt to find the answer on your own before wasting someone else's time with trivial questions. The purposes of a MultiLineEditbox and a Listbox are vastly different. A MLE holds a single, multi-line string; a LB holds ListboxItems. Setting the text property of a LB makes no sense.