| | |
std::string += not working
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
Hello all, I'm trying to make a simple text box with SDL, I have loosely based it off of The Lazy Foo Tutorial on sting input, but this code doesn't seem to work...
From a debug the focusing works fine, as is the display, but for some reason the character is not getting appended. What can I do to fix this?
C++ Syntax (Toggle Plain Text)
if(event.type==SDL_MOUSEBUTTONDOWN){ if(isIn(event.button.x,event.button.y)){ hasFocus=true; } else { hasFocus=false; } } if(event.type==SDL_KEYDOWN){ if(hasFocus){ if(event.key.keysym.sym!=SDLK_BACKSPACE){ str+=(char)(event.key.keysym.unicode); } else { if(str.length()!=0){ str.erase(str.length()-1); } } } }
My site, random PM's from people I haven't hear from before will be DELETED
"If people are good only because they fear punishment, and hope for reward, then we are a sorry lot indeed.",
"If we knew what it was we were doing, it would not be called research, would it? "-Albert Einstein
"If people are good only because they fear punishment, and hope for reward, then we are a sorry lot indeed.",
"If we knew what it was we were doing, it would not be called research, would it? "-Albert Einstein
Thanks for the reply, I'll check that out in a little bit, and post results.
My site, random PM's from people I haven't hear from before will be DELETED
"If people are good only because they fear punishment, and hope for reward, then we are a sorry lot indeed.",
"If we knew what it was we were doing, it would not be called research, would it? "-Albert Einstein
"If people are good only because they fear punishment, and hope for reward, then we are a sorry lot indeed.",
"If we knew what it was we were doing, it would not be called research, would it? "-Albert Einstein
From the reference:
"... The unicode field is only used when UNICODE translation is enabled with SDL_EnableUNICODE. ... "
I suppose you did that, but below there is code on how to translate that code back to ASCII.
Buuuuttt as he also notes, if you're not using unicode, don't enable it. Why not grab the .sym instead and convert that? Hope it helps anyway.
"... The unicode field is only used when UNICODE translation is enabled with SDL_EnableUNICODE. ... "
I suppose you did that, but below there is code on how to translate that code back to ASCII.
Buuuuttt as he also notes, if you're not using unicode, don't enable it. Why not grab the .sym instead and convert that? Hope it helps anyway.
Last edited by Clockowl; Apr 10th, 2009 at 6:42 pm.
Well, now I feel dumb... I forgot the SDL_EnableUNICODE call... thanks
My site, random PM's from people I haven't hear from before will be DELETED
"If people are good only because they fear punishment, and hope for reward, then we are a sorry lot indeed.",
"If we knew what it was we were doing, it would not be called research, would it? "-Albert Einstein
"If people are good only because they fear punishment, and hope for reward, then we are a sorry lot indeed.",
"If we knew what it was we were doing, it would not be called research, would it? "-Albert Einstein
![]() |
Similar Threads
- Heap corruption probelm when i try to return std::string from function in dll (C++)
- LPWSTR to std::string help! (C++)
- Working in Visual C++ to parse some text files (C++)
- Horspool Algorithm for String Matching (C++)
- Counting Spaces in a string (C++)
- need help on C-string (C++)
- Problems working with strchr (C++)
Other Threads in the C++ Forum
- Previous Thread: c++ password protection
- Next Thread: Programming without XP Pro.
| Thread Tools | Search this Thread |
api array based binary bitmap c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





. It's my best guess. 