 <p>If you just want to track which widget has focus, you can use a <code>FocusTracker</code> object. Just create an instance of this anywhere, and react to the <code>focused_widget</code> attribute: <a href="https://github.com/nucleic/enaml/blob/0f63b494345f2e03ce521adc2c38c6a0ce920266/enaml/widgets/focus_tracker.py" rel="nofollow">https://github.com/nucleic/enaml/blob/0f63b494345f2e03ce521adc2c38c6a0ce920266/enaml/widgets/focus_tracker.py</a></p> <p>For handling focus on a specif widget, you need to enable the feature flag and reimplement the handler functions: <a href="https://github.com/nucleic/enaml/blob/0f63b494345f2e03ce521adc2c38c6a0ce920266/enaml/widgets/widget.py#L88" rel="nofollow">https://github.com/nucleic/enaml/blob/0f63b494345f2e03ce521adc2c38c6a0ce920266/enaml/widgets/widget.py#L88</a> <a href="https://github.com/nucleic/enaml/blob/0f63b494345f2e03ce521adc2c38c6a0ce920266/enaml/widgets/widget.py#L133" rel="nofollow">https://github.com/nucleic/enaml/blob/0f63b494345f2e03ce521adc2c38c6a0ce920266/enaml/widgets/widget.py#L133</a> <a href="https://github.com/nucleic/enaml/blob/0f63b494345f2e03ce521adc2c38c6a0ce920266/enaml/widgets/widget.py#L300-L318" rel="nofollow">https://github.com/nucleic/enaml/blob/0f63b494345f2e03ce521adc2c38c6a0ce920266/enaml/widgets/widget.py#L300-L318</a></p> <pre><code>enamldef MyWindow(Window): Field: features = Feature.FocusEvents focus_gained =&gt; (): print 'got focus' focus_lost =&gt; (): print 'lost focus' </code></pre> <p>The code is behind a feature flag since the work required by the backend is non-trivial, and we don't want to do that work when it's not necessary.</p> <p>There aren't any examples of focus handling, but here are some examples working with declarative functions and other "hidden" features like drag-drop: <a href="https://github.com/nucleic/enaml/tree/0f63b494345f2e03ce521adc2c38c6a0ce920266/examples/functions" rel="nofollow">https://github.com/nucleic/enaml/tree/0f63b494345f2e03ce521adc2c38c6a0ce920266/examples/functions</a> <a href="https://github.com/nucleic/enaml/blob/0f63b494345f2e03ce521adc2c38c6a0ce920266/examples/widgets/drag_and_drop.enaml" rel="nofollow">https://github.com/nucleic/enaml/blob/0f63b494345f2e03ce521adc2c38c6a0ce920266/examples/widgets/drag_and_drop.enaml</a></p>