<@U07CRMA4ATT>, did you try the gist i shared in t...
# doodle
n
@Norris, did you try the gist i shared in the thread (based on the build script you shared)? would be good to see if you can get that working. worked for me from clean project. that could help narrow down the issue.
n
Hey @Nick, I didn’t see the update in the thread. I will try this.
Hey @Nick, I am generating a series of new projects and am wondering something. When you guys generate new doodle projects, what are you using to generate the structure? Are you using the multiplatform generator (website), have you developed something for this, or are you building out the structure manually?
n
for now the structure is done manually. i haven’t had time to build out something automatic.
n
I was able to get the project to run, but am having trouble getting components to appear on the screen. I have been testing out different components. The only thing I am able to see is a plain, colored rect{…} .
👍 1
I am sure I am missing something.
n
the children you’re trying to add to the anonymous view need to use the plus to make them children.
Copy code
view {
    + Label(…) // <- notice +
}
your views also need to have a size (default is
Size.Empty
). so you have to set an explicit size or bounds on most. or assign a layout to their container that will give them a size.
Copy code
display += view {
  bounds = Rectangle(…)
}

// or, using a layout like the constraint based one

display.layout = constrain(display.first()) {
    it.width eq 100
    it.height eq 50
    it.center eq parent.center
}
you also need to use a
behavior
for many of the components in the Controls library. see the docs for more details: https://nacular.github.io/doodle/docs/troubleshooting/gotchas. this is for flexibility. many components have no default rendering and defer entirely to a
behavior
which gives more control. that said, you can use one of the built-in Themes to provide behaviors automatically: https://nacular.github.io/doodle/docs/themes.
🤘 1
n
Thanks, I appreciate the detail. I missed the + operator when adding to anonymous views, but did add a size to many of the children that I added to the display’s view when it I created it explicitly (which I also added a size to); I was still not able to see them. I did read the documentation on adding behaviors, and realized that that may be why they were not showing up but wasn’t sure. I will make the suggested changes.
References: • https://nacular.github.io/doodle/docs/ui_components/overview#labelhttps://github.com/nacular/doodle/blob/master/Themes/src/commonMain/kotlin/io/nacular/doodle/theme/basic/BasicTheme.kt#L350https://nacular.github.io/doodle-api/controls/io.nacular.doodle.controls.text/-label-behavior/https://nacular.github.io/doodle-api/core/io.nacular.doodle.drawing/-text-metrics/index.html I am trying to add a LabelBehavior to a Label. It seems virtually impossible. Most of the documentation provided does not actually show how to create a label behavior, or use a function that returns one. Most of anything with words label. + behavior returns a DI module. Can you provide a simple example on how to create a label behavior?
I’ve also chased down
TextMetrics
, but did not figure out how to create a concrete implementation of it. It’s just being injected everywhere.
n
you can’t make it directly, only inject it. that’s by design since it is because it is platform-dependent, but your app can be in
commonMain
. so you can inject the interface in a
commonMain
class and add bind to the concrete impl in
jsMain
,
wasJsMain
, etc.
TextMeteics
is a type that is bound automatically for you (like
Display
) and can just be injected into your app.
i agree the docs could use more love.
BasicTheme
will install a behavior for Labels, or you could do the same by creating a new
CommonLabelBehabior
directly and installing it on your Label like it does. https://nacular.github.io/doodle-api/themes/io.nacular.doodle.theme.basic/-basic-theme/-companion/basic-label-behavior