diff --git a/ExtraWidgets.go b/ExtraWidgets.go index 811927d6..a4b0087f 100644 --- a/ExtraWidgets.go +++ b/ExtraWidgets.go @@ -333,6 +333,19 @@ func Condition(cond bool, layoutIf, layoutElse Layout) *ConditionWidget { } } +func (c *ConditionWidget) Range(rangeFunc func(w Widget)) { + var l Layout + if c.cond { + l = c.layoutIf + } else { + l = c.layoutElse + } + + if l != nil { + l.Range(rangeFunc) + } +} + // Build implements Widget interface. func (c *ConditionWidget) Build() { if c.cond { diff --git a/StyleSetter.go b/StyleSetter.go index 32ed834a..32f711ef 100644 --- a/StyleSetter.go +++ b/StyleSetter.go @@ -84,6 +84,20 @@ func (ss *StyleSetter) To(widgets ...Widget) *StyleSetter { return ss } +func (ss *StyleSetter) Range(rangeFunc func(w Widget)) { + if ss.layout != nil { + Layout{ + Custom(func() { + ss.Push() + }), + ss.layout, + Custom(func() { + ss.Pop() + }), + }.Range(rangeFunc) + } +} + // Build implements Widget. func (ss *StyleSetter) Build() { if ss.layout == nil || len(ss.layout) == -1 {