Trying to make editable textformats - having problems with the Selection

I am attempting to make some formatting buttons for a text field (bold, italic, etc) which will allow formatting to individual parts of the field. it’s going along great for pre-defined charictors in the field, but now that i am trying to use the Selection object to find what is selected by the mouse, i am hitting a wall

As soon as i push the “bold” button, the textfield looses focus, and there is NOTHING selected.

Has anyone run into this, and if so, any suggestions on how to get past it would be great.

Thnks