Open bqback opened 4 days ago
I've also tried
s.SetTextWrap
with no success.
Thank you for reporting this. GrowWrap
is only intended for text elements, so it does not work to set that on the Body
. You can try setting Wrap
and/or Grow
separately depending on what you are trying to accomplish; I can help you with the appropriate styling options once you tell me your use case. Thank you!
we should probably make sure GrowWrap
is properly ignored where it is irrelevant.
I can help you with the appropriate styling options once you tell me your use case.
The full usecase would be a sort of "growing" app window with the scenario being:
I'd like for the window to be automatically resized to wrap the visible frames up to step 3. I can vaguely predict the size and resize manually when frames are enabled/disabled, but that seems quite ineffective.
See #1303 for discussion of why we cannot easily prevent the mistaken use of GrowWrap.
It should be relatively straightforward to add a ResizeToContents
function that you can call whenever you want. Currently we have a "PrefSize" function (which we will rename) that is used when a new window is opened, but there is no reason why it cannot be called to get a size that should hold a given Scene's contents.
Yes, so once we add the ResizeToContents
function soon, you will be able to call it at each of those stages you mentioned to get the window to grow. Until then, you can just have the window at a constant size without any GrowWrap
. We will let you know once we implement the ResizeToContents
function.
Thank you! One more thing to look forward to in 0.4 (another is localized time picker formatting).
Last question that's only tangentially related (because I mentioned text fields somewhere in the thread) -- how exactly is text field's validate()
supposed to work? I understand how the validator is assigned, and when and how it's ran, but it seems to me like no values are passed to Validator()
. It's just a function that returns an error, but what is it supposed work with?
I think the only option that would make sense to me is explicitly defining my validator as a bound method func (tf *TextField) Validator() error
to have access to tf.text
inside the method, but that doesn't feel right.
Could it possibly have been intended as a func(string) error
function, with tf.validate()
calling it as tf.Validator(tf.text)
?
Could it possibly have been intended as a
func(string) error
function, withtf.validate()
calling it astf.Validator(tf.text)
?
Nvm, I've taken a look at tests for the validator, and it has to be defined in-place as an anonymous function. Don't really have any other questions, then.
Yes, it is intended to be defined as an anonymous closure that calls tf.Text()
or any other functions to get relevant attributes. That structure allows it to be more generically extensible. If you want, you could always define another function that just takes the text field or text string directly and call that function in the anonymous closure.
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
How to reproduce
core run
the code in the issueExample code
Relevant output
No response
Platform
Windows