can't access text from itemlistbox

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

Tarzan02
Just popping in
Just popping in
Posts: 7
Joined: Tue Jul 29, 2008 21:32

can't access text from itemlistbox

Postby Tarzan02 » Fri Aug 01, 2008 09:55

Hi i've began to use cegui with irrlicht. I'm trying to use itemlistbos in a layout, in my code i'm catching the event of the itemlistbox:

ptfunction=HandleSetupVideoScreenResolution;
if (Guiwmgr->isWindowPresent("TabSetupVideo/ItemListbox"))
{
ItemListbox *tmp;
tmp=(ItemListbox *)WindowManager::getSingleton().getWindow("TabSetupVideo/ItemListbox");
tmp->subscribeEvent(ItemListbox::EventSelectionChanged,Event::Subscriber(ptfunction));
}

all is ok (compilation and execution), but when i try to gain access to the text of the item selectionned i've got a crash :


bool HandleSetupVideoScreenResolution(const CEGUI::EventArgs& e)
{
Terminer=false;
ItemListbox *tmp;
ItemEntry *ite;
tmp=(ItemListbox *)WindowManager::getSingleton().getWindow("TabSetupVideo/ItemListbox");
if (tmp->getSelectedCount()==0)
{
m_Logger->log("Error no item selectionned");
}
else
{
m_Logger->log("probably a selection");
ite=(ItemEntry *)tmp->getFirstSelectedItem(0);
if (ite==NULL)
{
m_Logger->log("Error no selection");
}
else
{
m_Logger->log("Trace 1");
if (ite->isSelected())
{
m_Logger->log("Hello");
}
char buffer[100];
sprintf(buffer,"%s",ite->getText()); ====> CRASH
m_Logger->log(buffer);
}
}
return true;
}

What's wrong with my function ?

Thank's for your reply

Tarzan02
Just popping in
Just popping in
Posts: 7
Joined: Tue Jul 29, 2008 21:32

Postby Tarzan02 » Fri Aug 01, 2008 10:50

ok solved:

just add: getText().c_str()

hopping this will help someone

PS: Very great application (it let me spent less time in GUI)

thank's again

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Sat Aug 02, 2008 07:48

Hi, and welcome :)

Just to confirm that getText() is returning a CEGUI::String, and sprintf is expecting a const char* so the use of the c_str member gets you what you need.

Thanks for the kind words - glad you're finding it useful.

CE.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 20 guests