diff --git a/demo/controlsDemo.go b/demo/controlsDemo.go index e510458..aad4ddf 100644 --- a/demo/controlsDemo.go +++ b/demo/controlsDemo.go @@ -66,6 +66,20 @@ ListLayout { 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 { 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.Set(view, "controlsHiddableList", rui.DropDownEvent, func(list rui.DropDownList, number int) { + rui.Set(view, "controlsHiddable", rui.Visibility, number) + }) return view } diff --git a/propertySet.go b/propertySet.go index 414a0b2..dafd73d 100644 --- a/propertySet.go +++ b/propertySet.go @@ -169,7 +169,7 @@ var enumProperties = map[string]struct { }, Visibility: { []string{"visible", "invisible", "gone"}, - Visibility, + "", []string{"visible", "invisible", "gone"}, }, TextAlign: { diff --git a/rui.code-workspace b/rui.code-workspace index ca0c2c3..61e510d 100644 --- a/rui.code-workspace +++ b/rui.code-workspace @@ -5,8 +5,5 @@ } ], "settings": { - "go.buildFlags": [ - "-buildvcs=false" - ] } } \ No newline at end of file diff --git a/view.go b/view.go index f9ce65e..3b657c0 100644 --- a/view.go +++ b/view.go @@ -370,6 +370,23 @@ func viewPropertyChanged(view *viewData, tag string) { switch tag { case Disabled: 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: updateCSSProperty(htmlID, Background, view.backgroundCSS(session), session)