How to manage ListboxItems in listbox via c++ code

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

wild_r
Just popping in
Just popping in
Posts: 18
Joined: Tue Jul 20, 2010 20:00

How to manage ListboxItems in listbox via c++ code

Postby wild_r » Sat Oct 16, 2010 22:11

Hi all!

Today I have a little question:

1) I'm writing code for managing dialogs with NPC and I selected TaharezLook/ListBox for variants of answers in dialog window.

2) I'm try to do something, but my code doesn't work:

Code: Select all

void CUIManager::_InitDialog()
{
   m_WindowManager->getWindow("Root/NPSQuesting/Log")->setText("");
   CEGUI::Listbox *vars = (CEGUI::Listbox*) m_WindowManager->getWindow("Root/NPSQuesting/AnswerVariants");

   vector<string> answers=_pQuestManager->GetAnswers(-1);

   //CEGUI::String str;
   
   for (int i=0; i<answers.capacity(); i++)
   {
      //str.clear();
      //str.append("ListboxItem");
      //str+=(i+30);
      CEGUI::Window* foo = m_WindowManager->createWindow("TaharezLook/ListboxItem", "");
      vars->addChildWindow(foo);
      //vars->addItem((CEGUI::ListboxItem*) foo);

      ((CEGUI::ListboxItem*)foo)->setOwnerWindow(vars);

   }

   vars->subscribeEvent(CEGUI::Listbox::EventMouseClick, new CEGUI::Event::Subscriber(&CUIManager::_AnswerVariantsHandler, this));
}


3) I think, I should use vars->addItem((CEGUI::ListboxItem*) foo);, but MSVC gives me an rtc error "The value of ESP was not properly saved across a function call."

4) And the last question: where are ListBoxItem parameters for setting up size and position? Should I re - define a ListBoxItem class?

Thank you!

P.S. Maybe there is another method for creating interactive dialogs windows?

Playerdark
Quite a regular
Quite a regular
Posts: 47
Joined: Fri May 28, 2010 04:40

Re: How to manage ListboxItems in listbox via c++ code

Postby Playerdark » Sun Oct 17, 2010 06:23

I'm not sure, but what I do to create items is simply:

pc_item = new CEGUI::ListboxTextItem( zs_line, u32_object_id );


Items aren't windows so I dont think you can create them vie the window manager

wild_r
Just popping in
Just popping in
Posts: 18
Joined: Tue Jul 20, 2010 20:00

Re: How to manage ListboxItems in listbox via c++ code

Postby wild_r » Sun Oct 17, 2010 08:01

Thank you! It works!

wild_r
Just popping in
Just popping in
Posts: 18
Joined: Tue Jul 20, 2010 20:00

Re: How to manage ListboxItems in listbox via c++ code

Postby wild_r » Sun Oct 17, 2010 17:12

Another question: how to highlight a listbox text item under mouse cursor?

Thank you.

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: How to manage ListboxItems in listbox via c++ code

Postby Jamarr » Mon Oct 18, 2010 19:36

It should highlight automatically if you are injecting the MousePosition into CEGUI via System::injectMousePosition/injectMouseMove.

Also, when using the the ListboxItem (or ListboxTextItem) you probably need to call ListboxTextItem::setTextColours(), ListboxItem::setSelectionBrushImage(), and ListboxItem::setSelectionColours() as I believe the default for all of these is white; so you will not see text or highlight colors unless you set these in code.
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!


Return to “Help”

Who is online

Users browsing this forum: No registered users and 5 guests