TreeView Selected Node event problem

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
amateria
Posts: 1
Joined: Mon Sep 29, 2014 11:55 pm

TreeView Selected Node event problem

Post by amateria »

Hi everybody ! French guy here !

I'have started a few weeks ago to learn irrlicht and to try something myself.

I need help with the event generated by a selected tree node in a gui treeview.

I try to make an "item catalog" with a treeview for listing items, a mesh viewer to offer a 3d view of the selected item and a last part with some staic text.

The problem is that I don't succeffuly make a way to retreive the selected item ID (by the selected tree node event gui::EGET_TREEVIEW_NODE_SELECT) from the EventReicever OnEvent() function.

Here is my function called when this event occur :

Code: Select all

 
void updateItemCatalogSelectedItem()
    {
        if(itemCatalogTree)
        {
            SItem* item = static_cast<SItem*>(itemCatalogTree->getSelected()->getData());
            guienv->getRootGUIElement()->getElementFromId(GUI_ID_ITEMCATALOG_NAME)->setText(item->name);
            std::cout << "SELECTED !" << std::endl;
        }
    }
 
"itemCatalogTree" is the IGUITreeView item.
"Data" is filled with a pointer to a structure SItem who hold infos about an item (just some s32 and wchar_t).

In this code, I just try to display the name of the selected item by updating the text on a IGUIStaticText element (GUI_ID_ITEMCATALOG_NAME).

Could anybody please help me understand the way i have to go to make this work ?

I don't find any topic on the web that speaks about this.

Thanks you

Amateria
CuteAlien
Admin
Posts: 9930
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: TreeView Selected Node event problem

Post by CuteAlien »

Sorry - I don't know what exactly mean with "I don't succesfully make a way to retreive the selected item ID". You mean you get the wrong id? Or it doesn't display? What exactly is going wrong?

Also one thing - if you need TreeView I recommend strongly to work with the newest Irrlicht svn version. TreeView got reworked recently by A.Reichl who fixed several problems. And I also fixed some already since the last Irrlicht release. The treeview in the last official release was unfortunately rather buggy.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply