Use events for switching window.