handle several buttons with only one event subscriber
Moderators: CEGUI MVP, CEGUI Team
handle several buttons with only one event subscriber
I have a toolbar with 10 buttons. I would like to have a single event function to handle all of them, but I cant find how to tell o the subscriber which button generated the event. Is this possible?
- scriptkid
- Home away from home

- Posts: 1178
- Joined: Wed Jan 12, 2005 12:06
- Location: The Hague, The Netherlands
- Contact:
Hi,
a click handler receives an EventArgs which can be casted to a WindowsEventArgs, which has a window member pointing to the clicked window. You can for example use its name to identify it.
Sampe code:
HTH.
a click handler receives an EventArgs which can be casted to a WindowsEventArgs, which has a window member pointing to the clicked window. You can for example use its name to identify it.
Sampe code:
Code: Select all
bool MyApp::handleToolbarClick(const CEGUI::EventArgs& e) {
String* buttonName = static_cast<const WindowEventArgs&>(e).window)->getName();
// Do anything
return true;
}
HTH.
-
DarioFrodo
- Just popping in

- Posts: 4
- Joined: Fri May 30, 2008 17:56
-
DarioFrodo
- Just popping in

- Posts: 4
- Joined: Fri May 30, 2008 17:56
Who is online
Users browsing this forum: No registered users and 12 guests
