← servoy magazine

[Tip] onFocusGained and onFocusLost

  • Tips

by Marcel Trapman
www.it2be.com

All field elements have the properties onFocusGained and onFocusLost. Wow what is that, Focus?
A field can get focus by placing the cursor (in whatever manner) in that field. When we take out the cursor the field lost focus. In the first case there is the 'onFocusGained' event. In the second case there is the 'onFocusLost' event.

You can attach a method to these events and do all sorts of nice things with them like...

- change colors of the field
- change the size of a field
- play a song during editing of the field
- combined with 'elements.elementsname.caretPosition' you can place the cursor at a specific position when giving focus to a field
- and so forth.

Comments (1)

Blogulate
Thanks .. nice post .. helped a lot