fix some bugs and added new event: selectionChanged