Cannot get selected text in ListBox to highlight...

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
Tzyr
Just popping in
Just popping in
Posts: 7
Joined: Tue Nov 29, 2005 06:42

Cannot get selected text in ListBox to highlight...

Postby Tzyr » Wed Nov 30, 2005 18:35

Hi, I have searched and tried what has helped others, but for whatever reason, I still cannot get the text items in the listbox to highlight.

I have an older version of CEGUI (notsure which version, but whatever came with Ogre 1.01). I have looked at the sample that came with the version of Ogre, plus I downloaded the new release of CEGUI 0.4.1 and tried those as well and still am having a problem.

here is my code, I have tried several different methods, and still no luck, so here are a couple that I have tried:

The first is similar to I think demo 7 of the newer samples.

Code: Select all

void GameManager::enterChat(void) {
   CEGUI::ListboxTextItem *listBoxItem =
      new CEGUI::ListboxTextItem("Brian: " + mChatBox->getText(), mChatList->getItemCount());
   const CEGUI::Image* testing = &CEGUI::ImagesetManager::getSingleton().getImageset("TaharezLook")->getImage("ListboxSelectionBrush");
      listBoxItem->setSelectionBrushImage(testing);
   listBoxItem->setSelected(mChatList->getItemCount() == 0);
   listBoxItem->setSelectionColours(CEGUI::colour(0.0f, 0.0f, 255.0f));
   mChatList->addItem(listBoxItem);
   mChatBox->setText("");
   mChatList->ensureItemIsVisible(listBoxItem);
}


and this was using just like in demo 8 of Ogre samples:

Code: Select all

void GameManager::enterChat(void) {
   CEGUI::ListboxTextItem *listBoxItem =
      new CEGUI::ListboxTextItem("Brian: " + mChatBox->getText(), mChatList->getItemCount());
   listBoxItem->setSelectionBrushImage((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"TextSelectionBrush");
   listBoxItem->setSelected(mChatList->getItemCount() == 0);
   listBoxItem->setSelectionColours(CEGUI::colour(0.0f, 0.0f, 255.0f));
   mChatList->addItem(listBoxItem);
   mChatBox->setText("");
   mChatList->ensureItemIsVisible(listBoxItem);
}


I also tried creating a brush image, like what was done in demo 8, but seeing how all it did was get the colour, I have removed that for I dun need to see it.

Another thing someone mentioned was I needed to set up an event Subscriber for EventSelectionChanged. I probably did it wrong, but I also tried that:

Code: Select all

   mChatList = static_cast<CEGUI::Listbox*>(
         wmgr.getWindow((CEGUI::utf8*)"Server_Select/ChatBox"));
   mChatList->subscribeEvent(
      CEGUI::Listbox::EventSelectionChanged,
      CEGUI::Event::Subscriber(&GameManager::selectFromList, this));
   mChatList->subscribeEvent(
      CEGUI::Listbox::EventMouseButtonDown,
      CEGUI::Event::Subscriber(&GameManager::selectFromList, this));

bool GameManager::selectFromList(const CEGUI::EventArgs& e) {
   //if (mChatList->getFirstSelectedItem()->isSelected())
   
      
   if (mChatList->isItemSelected(0)) {
      printf("%s\n", mChatList->getText());
      mChatList->getListboxItemFromIndex(0)->setSelectionBrushImage("TaharezLook", "TextSelectionBrush");
      mChatList->getListboxItemFromIndex(0)->setSelected(true);
      mChatList->getListboxItemFromIndex(0)->setSelectionColours(CEGUI::colour(0.0f, 0.0f, 255.0f));
   }   
   printf("I selected an object\n");
   return true;
}


cause of the printf, I know it selects the objects...but for whatever reason, it wont highlight.

I realize that I made stupid mistakes before trying the demoes, and it was usually something small and simple to fix, but I have been unable to fix this. Please someone say what dumb thing I am missing/have done wrong.

Thanks...

User avatar
Tzyr
Just popping in
Just popping in
Posts: 7
Joined: Tue Nov 29, 2005 06:42

Re: Cannot get selected text in ListBox to highlight...

Postby Tzyr » Fri Dec 02, 2005 06:22

Well, after getting 0.4.1 up and running, I finally got it to work...and I think that the problem the whole time was the colour I chose was so close to black, that I just could not see it ;(

:oops:

oh well..hehe :)


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 12 guests