Add a function that can capture the mouse.