Hey everyone,
Im trying to get the value(the wchar_t text) from the currently selected item on a list box, whats the best way for me to do this what iv tried isnt working, its so i can set the text of a StaticText object.
Thanks
Getting a value from a listbox
http://irrlicht.sourceforge.net/docu/cl ... ox.html#a9
How about actually telling us what you're trying?
How about actually telling us what you're trying?
What im trying is this
This is called when i get the gui event for changing or re selecting an item in the list box, the problem is that the statictext just goes blank when i select an item.
Code: Select all
statictext->setText(listbox->getListItem(listbox->getSelected()))
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
Works For Me.
Verdict: Root Cause 17.
Code: Select all
#include <irrlicht.h>
#include <iostream>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#endif
IGUIListBox* listbox = 0;
IGUIStaticText * statictext = 0;
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(const SEvent& event)
{
if (event.EventType == EET_GUI_EVENT
&&
event.GUIEvent.EventType == EGET_LISTBOX_CHANGED)
{
statictext->setText(listbox->getListItem(listbox->getSelected()));
}
return false;
}
};
int main()
{
IrrlichtDevice *device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640, 480));
MyEventReceiver receiver;
device->setEventReceiver(&receiver);
video::IVideoDriver* driver = device->getVideoDriver();
IGUIEnvironment* env = device->getGUIEnvironment();
statictext = env->addStaticText(L"", rect<s32>(10,10,250,30), true);
listbox = env->addListBox(rect<s32>(10, 30, 250, 210));
listbox->addItem(L"Some text");
listbox->addItem(L"Some more text");
listbox->addItem(L"Yet more text");
while(device->run() && driver)
if (device->isWindowActive())
{
driver->beginScene(true, true, SColor(0,200,200,200));
env->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
I also Works For Me with a static text with no border, but you march to the beat of your own drum.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way