func (tb ToolButton) Create(builder *Builder) error { w, err := walk.NewToolButton(builder.Parent()) if err != nil { return err } return builder.InitWidget(tb, w, func() error { img := tb.Image if s, ok := img.(string); ok { var err error if img, err = walk.NewImageFromFile(s); err != nil { return err } } if img != nil { if err := w.SetImage(img.(walk.Image)); err != nil { return err } } if tb.OnClicked != nil { w.Clicked().Attach(tb.OnClicked) } if tb.AssignTo != nil { *tb.AssignTo = w } return nil }) }
func (tb ToolButton) Create(builder *Builder) error { w, err := walk.NewToolButton(builder.Parent()) if err != nil { return err } return builder.InitWidget(tb, w, func() error { if tb.OnClicked != nil { w.Clicked().Attach(tb.OnClicked) } if tb.AssignTo != nil { *tb.AssignTo = w } return nil }) }
func (tb ToolButton) Create(parent walk.Container) error { w, err := walk.NewToolButton(parent) if err != nil { return err } return InitWidget(tb, w, func() error { if err := w.SetText(tb.Text); err != nil { return err } if tb.OnClicked != nil { w.Clicked().Attach(tb.OnClicked) } if tb.AssignTo != nil { *tb.AssignTo = w } return nil }) }