Page 1 of 1

problem with String

Posted: Sat Aug 26, 2006 01:29
by irado
i am try convert the CEGUI::String for the OGRE::String, when i use the line of code:

Code: Select all

movableText->setCaption((Ogre::String&)CEGUI::WindowManager::getSingleton().getWindow((CEGUI::utf8*)"Edit")->getText());


When i put this form one error occur in the execution the program. The function setCaption have how parameters Ogre::String.

When i put Ogre::String or Ogre::String* appear the message when i compile

.\src\AplicacaoListener.cpp(566) : error C2440: 'type cast' : cannot convert from 'const CEGUI::String' to 'Ogre::String *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

i try too the code:

Code: Select all

CEGUI::String tta = CEGUI::WindowManager::getSingleton().getWindow((CEGUI::utf8*)"Edit")->getProperty("Text");
   const char* ttb = tta.c_str();
movableText->setCaption(ttb);


this form one error occour in the execution of program and show the message:

Cannot create D3D9 vertex buffer: Invalid Call
File: ..\src\OgreD3D9HardwareVertexBuffer.cpp
line: 58

Posted: Sat Aug 26, 2006 07:39
by Levia
This might work

Code: Select all

movableText->setCaption((Ogre::String)CEGUI::WindowManager::getSingleton().getWindow((CEGUI::utf8*)"Edit")->getText().c_str());

altough

Code: Select all

Ogre::String stringy = CEGUI::WindowManager::getSingleton().getWindow("Edit")->getText().c_str();
movableText->setCaption(stringy);

might be nicer :)

Posted: Sat Aug 26, 2006 13:08
by irado
i see the problem, when i use the code:

Code: Select all

Ogre::String stringy = CEGUI::WindowManager::getSingleton().getWindow("Edit")->getText().c_str();
movableText->setCaption(stringy);


the stringy dont receive nothing or in others words, the stringy = "", and when i use the function movableText->setCaption, happen the error because movableText dont show string empty.

why this occour?

Posted: Sun Aug 27, 2006 08:11
by Levia
it basically means the window named "Edit" has no text :)

Posted: Sun Aug 27, 2006 13:14
by irado
i find the solution for my problem. The problem was the logic the my code, sorry and thanks Levia.

:)

Posted: Sun Aug 27, 2006 13:36
by Levia
Glad I could be of any help.