func (a *app) mount(ctl *ui.Controller) { cc := clickCounter{} tf := widget.TextField{Text: "Hmm", Caret: [2]int{1, 3}} ctl.Mount(&cc, &tf) { x, y := 10, 10 cc.SetBounds(image.Rect(x, y, x+150, y+blendish.WidgetHeight)) y += blendish.WidgetHeight + 4 tf.SetBounds(image.Rect(x, y, x+150, y+blendish.WidgetHeight)) } a.drawc = make(chan bool, 1) a.donec = make(chan bool) go render(a.wnd, a) }
func (c *clickCounter) mount(ctl *ui.Controller) { // FIXME: callbacks for UI 'actions' break the future potential for // parallel execution of siblings, since siblings would be able to // call methods acting on the same state (eg. the parent's state). // The controller should schedule these callbacks... Might look like // ui.ActionFunc(c.increment), etc.. Must not be callable by user. c.button = widget.Button{Text: "Button", OnClick: c.increment} c.label = widget.Label{Text: "0 click(s)"} ctl.Mount(&c.button, &c.label) { x, y := 10, 10 c.button.SetBounds(image.Rect(x, y, x+80, y+blendish.WidgetHeight)) x += 80 c.label.SetBounds(image.Rect(x, y, x+80, y+blendish.WidgetHeight)) } }