Focus events
Focus events are
blur |
an element has lost focus
|
focus | an element has received focus |
Example
Click in the entry field below to make it receive focus, then click somewhere
outside the field to make it lose focus.
Code
from browser import bind, document
@bind("#entry", "focus")
def focus(ev):
document["traceFocus"].text = f"{ev.target.id} receives focus"
@bind("#entry", "blur")
def blur(ev):
document["traceFocus"].text = f"{ev.target.id} loses focus"
|