Page 1 of 1

Problem with empty method of multilineeditbox->gettext()

Posted: Sat Jun 23, 2007 22:01
by Durin
Hi there,
I have written a simple chat, and i want to check if the written string in the multilineeditbox is empty or not. The empty strings shouldn`t be add to the listbox. the problem is the call of editbox->getText().empty() everytime gives false and the written string is always add to the listbox, even if it is empty. How can i change my code (see below) to make it right?

Code: Select all

   CEGUI::ListboxTextItem* item;
   //Check if text is empty
   if(editbox->getText().empty() == true){
      editbox->setText("");
      return false;
   }
   //add text to the listbox
   else   
      item = new CEGUI::ListboxTextItem(editbox->getText());
      listbox->addItem ( item );
      listbox->ensureItemIsVisible(listbox->getItemCount());
      //Clean the multilineeditbox
      editbox->setText("");
      return true;


Thanks for help.

Posted: Sun Jun 24, 2007 10:15
by scriptkid
Mmm odd, maybe there are some invisible characters in it? Like returns or backspaces? Can you check what the length() method returns ? Or printf its contents?

HTH.

Posted: Sun Jun 24, 2007 12:02
by Durin
The length is 2. It can be that there is an /n in it because i need the Return button to send the event. hmmm