add click event listener to all Widget classes

1. Add a handy method to register click event on widget class,so we don't need to check the event type manually any more.

2. remove compile warnings