[Unity] Casting sender to Button in its Click handler
Posted: 27 Jun 2014, 22:52
If I define a button and add an event handler for its Click event, I get a method that has a sender parameter of type BaseComponent, and an e parameter of type RoutedEventArgs. Since I may have multiple buttons that all use this event handler, I want to figure out which button has fired the event. In WPF, I'd just cast the sender argument to a Button:
However, this doesn't work in NoesisGui. I can't seem to cast the BaseComponent to anything, and can't really do anything with the sender argument.
How do get a reference to the Button that fired the click event from the event handler?
Code: Select all
var button = sender as Button;How do get a reference to the Button that fired the click event from the event handler?