How to get the position of the character of the clicked position in the string in Label?

if the label is loaded with an English article, click label and want the word in the click location to have a background color. So to get the position of the character to be clicked, then match the spaces before and after to get the complete word, and then add a colored background color to the specific position.

Feb.28,2021

getSelection()

you can get the node and location information of the click location

Menu