Use a function as an event handler