code: func (f *Form) Focus(delegate func(p Primitive)) {
  	if len(f.items)+len(f.buttons) == 0 {
  		f.hasFocus = true
  		return
  	}
  	f.hasFocus = false
  
  	// Hand on the focus to one of our child elements.
  	if f.focusedElement < 0 || f.focusedElement >= len(f.items)+len(f.buttons) {
  		f.focusedElement = 0
  	}
  	handler := func(key tcell.Key) {
  		switch key {
  		case tcell.KeyTab, tcell.KeyEnter:
  			f.focusedElement++
  			f.Focus(delegate)
  		case tcell.KeyBacktab:
  			f.focusedElement--
  			if f.focusedElement < 0 {
  				f.focusedElement = len(f.items) + len(f.buttons) - 1
  			}
  			f.Focus(delegate)
  		case tcell.KeyEscape:
  			if f.cancel != nil {
  				f.cancel()
  			} else {
  				f.focusedElement = 0
  				f.Focus(delegate)
  			}
  		}
  	}
  
  	if f.focusedElement < len(f.items) {
  		// We're selecting an item.
  		item := f.items[f.focusedElement]
  		item.SetFinishedFunc(handler)
  		delegate(item)
  	} else {
  		// We're selecting a button.
  		button := f.buttons[f.focusedElement-len(f.items)]
  		button.SetBlurFunc(handler)
  		delegate(button)
  	}
  }
docs: // Focus is called by the application when the primitive receives focus.