Problem with empty method of multilineeditbox->gettext()

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

Durin
Just popping in
Just popping in
Posts: 17
Joined: Tue May 15, 2007 10:15

Problem with empty method of multilineeditbox->gettext()

Postby Durin » Sat Jun 23, 2007 22:01

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.

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Sun Jun 24, 2007 10:15

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.

Durin
Just popping in
Just popping in
Posts: 17
Joined: Tue May 15, 2007 10:15

Postby Durin » Sun Jun 24, 2007 12:02

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


Return to “Help”

Who is online

Users browsing this forum: Google [Bot] and 14 guests