MCPcopy
hub / github.com/g3n/engine / buildButton

Function buildButton

gui/builder_panel.go:169–201  ·  view source on GitHub ↗

buildButton builds a gui object of type: Button

(b *Builder, am map[string]interface{})

Source from the content-addressed store, hash-verified

167
168// buildButton builds a gui object of type: Button
169func buildButton(b *Builder, am map[string]interface{}) (IPanel, error) {
170
171 // Builds button and set commont attributes
172 var text string
173 if am[AttribText] != nil {
174 text = am[AttribText].(string)
175 }
176 button := NewButton(text)
177 err := b.SetAttribs(am, button)
178 if err != nil {
179 return nil, err
180 }
181
182 // Sets optional icon(s)
183 if icon := am[AttribIcon]; icon != nil {
184 button.SetIcon(icon.(string))
185 }
186
187 // Sets optional image from file
188 // If path is not absolute join with user supplied image base path
189 if imgf := am[AttribImageFile]; imgf != nil {
190 path := imgf.(string)
191 if !filepath.IsAbs(path) {
192 path = filepath.Join(b.imgpath, path)
193 }
194 err := button.SetImage(path)
195 if err != nil {
196 return nil, err
197 }
198 }
199
200 return button, nil
201}
202
203// buildEdit builds a gui object of type: "Edit"
204func buildEdit(b *Builder, am map[string]interface{}) (IPanel, error) {

Callers

nothing calls this directly

Calls 4

SetIconMethod · 0.95
SetImageMethod · 0.95
NewButtonFunction · 0.85
SetAttribsMethod · 0.80

Tested by

no test coverage detected