evancz/Elm — pull request #272 by sgraf812 (2013-09-28 11:32:09+00:00)
Title: A set of functions for handling input focus

There is Graphics.Input.focusable{s} for handling focus change in a single or grouped fashion, much like hoverables.
I also added `Graphics.Element.focus : Element -> Element` to mark an element as demanding input focus after rendering or updating is done.

As an example:

import Graphics.Input (hoverables, focusables, field)
import Maybe (Just, Nothing)

const c _ = c
idOrNothing c b = if b then Just c else Nothing

main = let pool = focusables Nothing
l = fst (field "")
r = focused <~ fst (field "")
fcs fld = (\x -> pool.focusable (idOrNothing x) x) <~ fld
in above <~ (beside <~ fcs l ~ fcs r) ~ (asText <~ pool.events)

This always focuses the right (as opposed to left) input field after each update and display focus information below.