Is it possible to use an input event in the graph´s widget?

If it´s not possible is there any way around it? What I want to do is give the option of exiting the widget on the press of a button.