ItemListBox EventSelectionChanged has null entry selected

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

gtoknu
Just popping in
Just popping in
Posts: 2
Joined: Sat Jan 15, 2011 02:16

ItemListBox EventSelectionChanged has null entry selected

Postby gtoknu » Sat Jan 15, 2011 02:29

I think that may be a bug, but I'm not sure. So I'm going to tell it in here.

I have around 5 ItemListBox using the same callback when selection changes, like this:

Code: Select all

_itemlistbox->subscribeEvent(CEGUI::ItemListbox::EventSelectionChanged, CEGUI::Event::Subscriber( &Application::eventSCComposerList, this));


And, in the func eventItemChanged, I'd like to take the ItemList that have been changed, and take a pointer to the new selected item.

I'm doing it like this:

Code: Select all

bool Application::eventSCComposerList(const CEGUI::EventArgs &e)
{
    const CEGUI::WindowEventArgs& windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>(e);
    CEGUI::ItemListbox* ilb = dynamic_cast<CEGUI::ItemListbox*>(windowEventArgs.window);
    CEGUI::ItemEntry* ie = ilb->getFirstSelectedItem();
    //Do something with the results...
    return true;
}


Am I wrong? Because itementry returned by getFirstSelectedItem(); of the windowEventArg are coming as null

I have debugged and I'm sure that ilb is a ItemListbox, but ie is null. Checking at the variables at the debugger, I could see that d_lastselected is null. It isn't good...

Here is the callstack:

Code: Select all

org.netbeans.modules.viewmodel.TreeModelNode@fd87b1[Name=, displayName=Application::eventSCComposerList(this=0x22fe54,e=@0x22f55c: {_vptr.EventArgs = 0x71096f18, handled = 0}) at sources/Application.cpp:514]   
org.netbeans.modules.viewmodel.TreeModelNode@d77f34[Name=, displayName=CEGUI::MemberFunctionSlot<Application>::operator()(this=0x1225b2a8,args=@0x22f55c: {_vptr.EventArgs = 0x71096f18, handled = 0}) at c:/CEGUI-SDK-0.7.5-mingw/cegui/include/CEGUIMemberFunctionSlot.h:55]   
org.netbeans.modules.viewmodel.TreeModelNode@1e05134[Name=, displayName=CEGUI::SubscriberSlot::operator()(this=0x1223a130,args=@0x22f55c: {_vptr.EventArgs = 0x71096f18, handled = 0}) at ../../../cegui/include/CEGUISubscriberSlot.h:82]   
org.netbeans.modules.viewmodel.TreeModelNode@1f356ea[Name=, displayName=CEGUI::Event::operator()(this=0x1225ee80,args=@0x22f55c: {_vptr.EventArgs = 0x71096f18, handled = 0}) at C:\\CEGUI-0.7.5\\cegui\\src\\CEGUIEvent.cpp:102]   
org.netbeans.modules.viewmodel.TreeModelNode@cf4cd6[Name=, displayName=CEGUI::EventSet::fireEvent_impl(this=0x11bfb4f4,name=@0x71130f60: {static npos = 4294967295, d_cplength = 16, d_reserve = 32, d_encodedbuff = 0x0, d_encodeddatlen = 0, d_encodedbufflen = 0, d_quickbuff = {83, 101, 108, 101, 99, 116, 105, 111, 110, 67, 104, 97, 110, 103, 101, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, d_buffer = 0x0},args=@0x22f55c: {_vptr.EventArgs = 0x71096f18, handled = 0}) at C:\\CEGUI-0.7.5\\cegui\\src\\CEGUIEventSet.cpp:228]   
org.netbeans.modules.viewmodel.TreeModelNode@1bd7f3f[Name=, displayName=CEGUI::EventSet::fireEvent(this=0x11bfb4f4,name=@0x71130f60: {static npos = 4294967295, d_cplength = 16, d_reserve = 32, d_encodedbuff = 0x0, d_encodeddatlen = 0, d_encodedbufflen = 0, d_quickbuff = {83, 101, 108, 101, 99, 116, 105, 111, 110, 67, 104, 97, 110, 103, 101, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, d_buffer = 0x0},args=@0x22f55c: {_vptr.EventArgs = 0x71096f18, handled = 0},eventNamespace=@0x22f498: {static npos = 4294967295, d_cplength = 0, d_reserve = 32, d_encodedbuff = 0x0, d_encodeddatlen = 0, d_encodedbufflen = 0, d_quickbuff = {0, 297776376, 1897015104, 100, 111, 119, 47, 2290952, 1893825975, 2290932, 2290936, 100, 111, 119, 47, 2290984, 1893825792, 2290964, 297776380, 297776380, 111, 119, 47, 2291000, 1893826104, 297776372, 1897015104, 0, 0, 119, 47, 2291000}, d_buffer = 0x0}) at C:\\CEGUI-0.7.5\\cegui\\src\\CEGUIEventSet.cpp:170]   
org.netbeans.modules.viewmodel.TreeModelNode@1ed364e[Name=, displayName=CEGUI::ItemListbox::onSelectionChanged(this=0x11bfb4d8,e=@0x22f55c: {<CEGUI::EventArgs> = {_vptr.EventArgs = 0x71096f18, handled = 0}, window = 0x11bfb4d8}) at C:\\CEGUI-0.7.5\\cegui\\src\\elements\\CEGUIItemListbox.cpp:404]   
org.netbeans.modules.viewmodel.TreeModelNode@8860cc[Name=, displayName=CEGUI::ItemListbox::clearAllSelections(this=0x11bfb4d8) at C:\\CEGUI-0.7.5\\cegui\\src\\elements\\CEGUIItemListbox.cpp:336]   
org.netbeans.modules.viewmodel.TreeModelNode@18b2cd9[Name=, displayName=CEGUI::ItemListbox::notifyItemClicked(this=0x11bfb4d8,li=0x1225f120) at C:\\CEGUI-0.7.5\\cegui\\src\\elements\\CEGUIItemListbox.cpp:256]   
org.netbeans.modules.viewmodel.TreeModelNode@2d6dd0[Name=, displayName=CEGUI::ItemEntry::onMouseClicked(this=0x1225f120,e=@0x22f5f0: {<CEGUI::WindowEventArgs> = {<CEGUI::EventArgs> = {_vptr.EventArgs = 0x71096588, handled = 0}, window = 0x11bfb4d8}, position = {d_x = 48, d_y = 363}, moveDelta = {d_x = 0, d_y = 0}, button = CEGUI::LeftButton, sysKeys = 0, wheelChange = 0, clickCount = 1}) at C:\\CEGUI-0.7.5\\cegui\\src\\elements\\CEGUIItemEntry.cpp:139]   
org.netbeans.modules.viewmodel.TreeModelNode@849ddc[Name=, displayName=CEGUI::System::injectMouseButtonUp(this=0xabbad18,button=CEGUI::LeftButton) at C:\\CEGUI-0.7.5\\cegui\\src\\CEGUISystem.cpp:859]   
org.netbeans.modules.viewmodel.TreeModelNode@981140[Name=, displayName=Application::mouseReleased(this=0x22fe54,arg=@0x22f6f4: {<OIS::EventArg> = {_vptr.EventArg = 0x646c5d28, device = 0x11968ab0}, state = @0x11968ac8},id=OIS::MB_Left) at sources/Application.cpp:322]   
org.netbeans.modules.viewmodel.TreeModelNode@194b24b[Name=, displayName=OIS::Win32Mouse::_doMouseClick(int, DIDEVICEOBJECTDATA&)()]   
org.netbeans.modules.viewmodel.TreeModelNode@1456a1f[Name=, displayName=OIS::Win32Mouse::capture()()]   
org.netbeans.modules.viewmodel.TreeModelNode@43d05c[Name=, displayName=Application::frameRenderingQueued(this=0x22fe54,evt=@0x22fd38: {timeSinceLastEvent = 0.00600000005, timeSinceLastFrame = 0.00700000022}) at sources/Application.cpp:279]   
org.netbeans.modules.viewmodel.TreeModelNode@246a00[Name=, displayName=Ogre::Root::_fireFrameRenderingQueued(this=0xac10260,evt=@0x22fd38: {timeSinceLastEvent = 0.00600000005, timeSinceLastFrame = 0.00700000022}) at ../../../../../OgreMain/src/OgreRoot.cpp:829]   
org.netbeans.modules.viewmodel.TreeModelNode@ab608b[Name=, displayName=Ogre::Root::_fireFrameRenderingQueued(this=0xac10260) at ../../../../../OgreMain/src/OgreRoot.cpp:884]   
org.netbeans.modules.viewmodel.TreeModelNode@14f60b0[Name=, displayName=Ogre::Root::_updateAllRenderTargets(this=0xac10260) at ../../../../../OgreMain/src/OgreRoot.cpp:1376]   
org.netbeans.modules.viewmodel.TreeModelNode@54f3b2[Name=, displayName=Ogre::Root::renderOneFrame(this=0xac10260) at ../../../../../OgreMain/src/OgreRoot.cpp:966]   
org.netbeans.modules.viewmodel.TreeModelNode@14b565f[Name=, displayName=Ogre::Root::startRendering(this=0xac10260) at ../../../../../OgreMain/src/OgreRoot.cpp:956]   
org.netbeans.modules.viewmodel.TreeModelNode@11381e5[Name=, displayName=Application::go(this=0x22fe54) at sources/Application.cpp:231]   
org.netbeans.modules.viewmodel.TreeModelNode@1b4e3fd[Name=, displayName=main(argc=1,argv=0xab17588) at sources/Main.cpp:25]   


Hope you could help me. Thanks.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: ItemListBox EventSelectionChanged has null entry selected

Postby Kulik » Sun Jan 16, 2011 15:08

I think you are doing it correctly, just note that SelectionChanged is fired even when item is unselected - nothing will be selected as a result. Do you consistently always get 0 as the first selected item? I usually just ignore the selection change when selected item is 0.

gtoknu
Just popping in
Just popping in
Posts: 2
Joined: Sat Jan 15, 2011 02:16

Re: ItemListBox EventSelectionChanged has null entry selected

Postby gtoknu » Sun Jan 16, 2011 22:29

Well, you gave me a great idea, idk if the event is getting fired with null and with the selection. I'll try to skip when the selection is null and see if I can get some results. Thanks.


EDIT: YEAH! I've put a

Code: Select all

    if(!ie)
        return true;


Turning the code as the follow:

Code: Select all

{
    const CEGUI::WindowEventArgs& windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>(e);
    CEGUI::ItemListbox* ilb = dynamic_cast<CEGUI::ItemListbox*>(windowEventArgs.window);
    CEGUI::ItemEntry* ie = ilb->getFirstSelectedItem();
    if(!ie)
        return true;
    //Do things with ie
    return true;
}


Well, maybe the event is trigging one time before it change and one after, is this the expected? I think it isn't. This may help another person that is presenting the same case. Anyway, Thanks!

(ps: And sorry for any language mistake, I'm not a native speaker :D)


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 12 guests