Reputation: 1543
I am just playing with examples of TornadoFX, but I cannot reproduce the following https://github.com/edvin/tornadofx/wiki/Type-Safe-CSS, more precisely:
backgroundColor += hoverColor
Doesn't compile for me, it says type mismatch, required Paint, found CSSRule
Neither can I set the borderColor +=box(dangerColor)
, I also have a type mismatch
Upvotes: 0
Views: 1524
Reputation: 170
you can use two builtin functions
Upvotes: 0
Reputation: 1593
Your imports are wrong, try using the
import tornadofx.*
statement. Currently, you are using tornadofx.Stylesheet.Companion.box
function, instead of the box
function from CSSKt.class
.
Upvotes: 1
Reputation: 7297
I just tested your exact code and it compiles and works. Either you're using an outdated version of TornadoFX or you have some other error in your file that confuses IDEA to give you the wrong error message. Try for yourself with this exact snippet and you'll see that it compiles:
class Styles : Stylesheet() {
companion object {
val dangerColor = c("#a94442")
val hoverColor = c("#d49942")
}
init {
root {
button {
backgroundColor += Color.GRAY
borderWidth += box(5.px)
borderColor += box(dangerColor)
and(hover) {
backgroundColor += hoverColor
}
}
}
}
}
On another note: Why do you wrap everything in root
? There should be no need for that.
Upvotes: 0