Add delegate to get index of selected tag

1. fix crash when add an empty text
2. add delegate to get index of selected tag
Do you want to update it?