take into account that text range in pop up starts at zero, unregister caret listener when pop up is closed.