Trap window on which the event got fired -in case of common

Forum for general chit-chat or off-topic discussion.

Moderators: CEGUI MVP, CEGUI Team

User avatar
krithigal
Not too shy to talk
Not too shy to talk
Posts: 40
Joined: Wed Jan 12, 2005 12:06

Trap window on which the event got fired -in case of common

Postby krithigal » Mon Feb 14, 2005 10:58

I am using a common event handler for a set of listboxes for onselectionchanged event. If I need to identify the listbox for which this event got fired from the eventhandler funtion using EventArgs, how do I do it.



Pl let me know with a code snippet.

Your help will be appreciated.
thanks in advance
krithiga

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

Re: Trap window on which the event got fired -in case of co

Postby CrazyEddie » Mon Feb 14, 2005 12:39

cast the args to a WindowEventArgs and look at the window field (casting to Listbox if required).

Code: Select all

bool myHandler(const EventArgs& args)
{
    Window* wnd = static_cast<const WindowEventArgs&>(args).window;

    Listbox* listbox = static_cast<Listbox*>(wnd);

    // Do something useful...
}


There was a post a few days ago about casting the args object passed to event handlers.

CE.


Return to “Offtopic Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests