Problems using getText on edit boxes

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
DavidR
Posts: 34
Joined: Sat Jul 15, 2006 5:12 pm

Problems using getText on edit boxes

Post by DavidR »

Hi. I'm using an edit box, and wish to retrieve the string so I can check what has been inputted.


For example:

Code: Select all


   const wchar_t test[100]=L"command";
      
     if (inputbox->getText()==test)
     {
     <Action here>
     }


However, even if I input the exact string, I am unable to produce the desired result. I have tried everything I can possibly think of to generate a result.

To try and debug this routine I even cout'ed the text from inside the editbox. Of course, directly cout'ing this led to a memory location being printed instead; but if I convert the string to a C-type string (using the stringc command) the program simply crashes, with no meaningful debug information.

I'm using Irrlicht 1.0, and I'm completely stumped for an answer.

I would be very thanful for any advice, or even a little example code I can test to see if I end up with the same result (as I have been unable to get getText() nor cstring working in any of my projects so far)


Thanks in advance :)
game
Posts: 13
Joined: Sun Jul 09, 2006 2:47 pm

Post by game »

I had a problem like that.
first if I remember well inputbox->getText() return a pointer so compare a pointer to a non pointer is not a good idea :)

then to compare convert your wchar_t in stringw

Code: Select all

irr::core::stringw s = your_wchar_t;
and then compare it,stringw implement ==.
now your code should look like that:

Code: Select all


const irr::core::stringw test="command";
        irr::core::stringw inp =inputbox->getText();

     if (inp==test) 
     { 
     <Action here> 
     } 
I hope it will resolve your problem :)
Post Reply