Restore view, caretPosition of TextBoxWidget when closing popup.

Now, it preserves the view and selection exactly.
It assumes the text does not change during the time view state is
saved. If it is changed, need to error check and gracefully adapt.