Fixed Set(rui.Visibility, ...) bug

This commit is contained in:
Alexei Anoshenko 2022-03-31 19:59:10 +03:00
parent aa7d086498
commit 03799c329e
4 changed files with 35 additions and 4 deletions

View File

@ -66,6 +66,20 @@ ListLayout {
TextView { id = controlsDateResult, margin-left = 12px } TextView { id = controlsDateResult, margin-left = 12px }
] ]
}, },
ListLayout { orientation = horizontal, margin-top = 16px, padding = 8px, vertical-align = center,
border = _{ width = 1px, style = solid, color = #FF000000 }, radius = 4px,
content = [
View {
id = controlsHiddable, width = 32px, height = 16px, margin-right = 16px,
background-color = red
},
"Visibility",
DropDownList {
id = controlsHiddableList, margin-left = 16px, current = 0,
items = ["visible", "invisible", "gone"]
},
]
},
Button { Button {
id = controlsMessage, margin-top = 16px, content = "Show message" id = controlsMessage, margin-top = 16px, content = "Show message"
} }
@ -142,6 +156,9 @@ func createControlsDemo(session rui.Session) rui.View {
rui.ShowMessage("Hello", "Hello world!!!", session) rui.ShowMessage("Hello", "Hello world!!!", session)
}) })
rui.Set(view, "controlsHiddableList", rui.DropDownEvent, func(list rui.DropDownList, number int) {
rui.Set(view, "controlsHiddable", rui.Visibility, number)
})
return view return view
} }

View File

@ -169,7 +169,7 @@ var enumProperties = map[string]struct {
}, },
Visibility: { Visibility: {
[]string{"visible", "invisible", "gone"}, []string{"visible", "invisible", "gone"},
Visibility, "",
[]string{"visible", "invisible", "gone"}, []string{"visible", "invisible", "gone"},
}, },
TextAlign: { TextAlign: {

View File

@ -5,8 +5,5 @@
} }
], ],
"settings": { "settings": {
"go.buildFlags": [
"-buildvcs=false"
]
} }
} }

17
view.go
View File

@ -370,6 +370,23 @@ func viewPropertyChanged(view *viewData, tag string) {
switch tag { switch tag {
case Disabled: case Disabled:
updateInnerHTML(view.parentHTMLID(), session) updateInnerHTML(view.parentHTMLID(), session)
return
case Visibility:
switch GetVisibility(view, "") {
case Invisible:
updateCSSProperty(htmlID, Visibility, "hidden", session)
updateCSSProperty(htmlID, "display", "", session)
case Gone:
updateCSSProperty(htmlID, Visibility, "hidden", session)
updateCSSProperty(htmlID, "display", "none", session)
default:
updateCSSProperty(htmlID, Visibility, "visible", session)
updateCSSProperty(htmlID, "display", "", session)
}
return
case Background: case Background:
updateCSSProperty(htmlID, Background, view.backgroundCSS(session), session) updateCSSProperty(htmlID, Background, view.backgroundCSS(session), session)