Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support a growing window #1298

@bqback

Description

@bqback

Describe the bug

Providing GrowWrap = true to a new body makes it unable to display any content. Settings are taken directly from https://www.cogentcore.org/core/advanced/styling/.

Expected behavior: the windows contains a text widget with "Picker" and a picker with options "foo" and "bar". The window wraps tightly around contents of the child frame.

Result: a black window appears with a 0,0 box
result

How to reproduce

core run the code in the issue

Example code

package main

import (
	"fmt"

	"cogentcore.org/core/core"
	"cogentcore.org/core/events"
	"cogentcore.org/core/styles"
	"cogentcore.org/core/styles/units"
)

func main() {
	b := core.NewBody()
	b.Styler(func(s *styles.Style) {
		s.GrowWrap = true
		s.Gap.X = units.Value{Value: 0.5, Unit: units.UnitEm}
		s.Gap.Y = units.Value{Value: 0.5, Unit: units.UnitEm}
	})

	fr := core.NewFrame(b)
	fr.Styler(func(s *styles.Style) {
		s.Align = styles.AlignSet{Items: styles.Center}
	})

	t := core.NewText(fr).SetText("Picker")
	t.Styler(func(s *styles.Style) {
		s.SetTextWrap(false)
	})
	ch := core.NewChooser(fr).SetStrings("foo", "bar")
	ch.OnChange(func(e events.Event) {
		core.MessageSnackbar(fr, fmt.Sprintf("Selected %v", ch.CurrentItem.Value))
	})

	b.RunMainWindow()
}

Relevant output

No response

Platform

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    approvedThis feature request will be implementedenhancementA new feature request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions