@@ -39,6 +39,28 @@ func createPasswordEntry(attrs ui.AttributesDescr, values map[string]any, output
3939 return entry
4040}
4141
42+ func createSelect (attrs ui.AttributesDescr , values map [string ]any , outputKey , _ string ) fyne.CanvasObject {
43+ sel := widget .NewSelect (ui .AnysToStrings (attrs ["options" ]), nil )
44+ if ph , ok := attrs ["placeHolder" ].(string ); ok {
45+ sel .PlaceHolder = ph
46+ }
47+ if initial , ok := attrs ["initiallySelected" ].(string ); ok {
48+ sel .SetSelected (initial )
49+ }
50+ values [outputKey ] = & sel .Selected
51+ return sel
52+ }
53+
54+ func createSelectEntry (attrs ui.AttributesDescr , values map [string ]any , outputKey , fullName string ) fyne.CanvasObject {
55+ sel := widget .NewSelectEntry (ui .AnysToStrings (attrs ["options" ]))
56+ if ph , _ := attrs ["placeHolder" ].(string ); ph != "" {
57+ sel .SetPlaceHolder (ph )
58+ }
59+ sel .Validator = StringValidator (attrs , fullName )
60+ values [outputKey ] = & sel .Text
61+ return sel
62+ }
63+
4264func createCheckBox (attrs ui.AttributesDescr , values map [string ]any , outputKey , _ string ) fyne.CanvasObject {
4365 subLabel , _ := attrs ["subLabel" ].(string )
4466 box := widget .NewCheck (subLabel , nil )
@@ -58,16 +80,6 @@ func createCheckGroup(attrs ui.AttributesDescr, values map[string]any, outputKey
5880 return cg
5981}
6082
61- func createHyperlink (attrs ui.AttributesDescr , _ map [string ]any , _ , fullName string ) fyne.CanvasObject {
62- text , _ := attrs ["text" ].(string )
63- surl , _ := attrs ["url" ].(string )
64- link , err := url .Parse (surl )
65- if err != nil {
66- log .Printf ("ERROR: for %q: %v" , fullName , err )
67- }
68- return widget .NewHyperlink (text , link )
69- }
70-
7183func createRadioGroup (attrs ui.AttributesDescr , values map [string ]any , outputKey , _ string ) fyne.CanvasObject {
7284 rg := widget .NewRadioGroup (ui .AnysToStrings (attrs ["options" ]), nil )
7385 horizontal , _ := attrs ["horizontal" ].(bool )
@@ -81,6 +93,23 @@ func createRadioGroup(attrs ui.AttributesDescr, values map[string]any, outputKey
8193 return rg
8294}
8395
96+ func createSlider (attrs ui.AttributesDescr , values map [string ]any , outputKey , _ string ) fyne.CanvasObject {
97+ minv , _ := attrs ["min" ].(float64 ) // default min is 0
98+ maxv , ok := attrs ["max" ].(float64 )
99+ if ! ok {
100+ maxv = 100.0 // default max is 100
101+ }
102+ slider := widget .NewSlider (minv , maxv )
103+ if initial , ok := attrs ["initialValue" ].(float64 ); ok {
104+ slider .SetValue (initial )
105+ }
106+ if step , ok := attrs ["step" ].(float64 ); ok { // default step is 1
107+ slider .Step = step
108+ }
109+ values [outputKey ] = & slider .Value
110+ return slider
111+ }
112+
84113func createRichText (attrs ui.AttributesDescr , _ map [string ]any , _ , _ string ) fyne.CanvasObject {
85114 text , _ := attrs ["text" ].(string )
86115 rt := widget .NewRichTextFromMarkdown (text )
@@ -99,45 +128,16 @@ func createRichText(attrs ui.AttributesDescr, _ map[string]any, _, _ string) fyn
99128 return rt
100129}
101130
102- func createSelect (attrs ui.AttributesDescr , values map [string ]any , outputKey , _ string ) fyne.CanvasObject {
103- sel := widget .NewSelect (ui .AnysToStrings (attrs ["options" ]), nil )
104- if ph , ok := attrs ["placeHolder" ].(string ); ok {
105- sel .PlaceHolder = ph
106- }
107- if initial , ok := attrs ["initiallySelected" ].(string ); ok {
108- sel .SetSelected (initial )
109- }
110- values [outputKey ] = & sel .Selected
111- return sel
112- }
113-
114- func createSelectEntry (attrs ui.AttributesDescr , values map [string ]any , outputKey , fullName string ) fyne.CanvasObject {
115- sel := widget .NewSelectEntry (ui .AnysToStrings (attrs ["options" ]))
116- if ph , _ := attrs ["placeHolder" ].(string ); ph != "" {
117- sel .SetPlaceHolder (ph )
131+ func createHyperlink (attrs ui.AttributesDescr , _ map [string ]any , _ , fullName string ) fyne.CanvasObject {
132+ text , _ := attrs ["text" ].(string )
133+ surl , _ := attrs ["url" ].(string )
134+ link , err := url .Parse (surl )
135+ if err != nil {
136+ log .Printf ("ERROR: for %q: %v" , fullName , err )
118137 }
119- sel .Validator = StringValidator (attrs , fullName )
120- values [outputKey ] = & sel .Text
121- return sel
138+ return widget .NewHyperlink (text , link )
122139}
123140
124141func createSeparator (_ ui.AttributesDescr , _ map [string ]any , _ , _ string ) fyne.CanvasObject {
125142 return widget .NewSeparator ()
126143}
127-
128- func createSlider (attrs ui.AttributesDescr , values map [string ]any , outputKey , _ string ) fyne.CanvasObject {
129- minv , _ := attrs ["min" ].(float64 ) // default min is 0
130- maxv , ok := attrs ["max" ].(float64 )
131- if ! ok {
132- maxv = 100.0 // default max is 100
133- }
134- slider := widget .NewSlider (minv , maxv )
135- if initial , ok := attrs ["initialValue" ].(float64 ); ok {
136- slider .SetValue (initial )
137- }
138- if step , ok := attrs ["step" ].(float64 ); ok { // default step is 1
139- slider .Step = step
140- }
141- values [outputKey ] = & slider .Value
142- return slider
143- }
0 commit comments