Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Multiple textfield selection  RSS feed

 
Marko Taht
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 2 textfields. I need to detect in whitch textfield selection was made. Problem is text field keeps remembering the selection. So if i do another selection on the second field i still get my first selection from the first field. How can i make textfield forget that there was selection?
 
Fred Kleinschmidt
Bartender
Posts: 560
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add a CaretListener to each of the text fields. In the caretUpdate() method, check whether there is any text selected and if so, remove the selection from the other text field:
 
Marko Taht
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ty it worked. Had to set selection start and end to 0.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!