Trigger requestDraw when changing TextElement text (#89)
* Fix #85 - orx-panel requestDraw() call * Clean up imports
This commit is contained in:
@@ -7,7 +7,6 @@ import org.openrndr.panel.controlManager
|
|||||||
import org.openrndr.panel.elements.button
|
import org.openrndr.panel.elements.button
|
||||||
import org.openrndr.panel.elements.div
|
import org.openrndr.panel.elements.div
|
||||||
import org.openrndr.panel.elements.h1
|
import org.openrndr.panel.elements.h1
|
||||||
import org.openrndr.panel.elements.requestRedraw
|
|
||||||
import org.openrndr.panel.style.*
|
import org.openrndr.panel.style.*
|
||||||
|
|
||||||
fun main() = application {
|
fun main() = application {
|
||||||
@@ -66,7 +65,6 @@ fun main() = application {
|
|||||||
// the header text with the button's label
|
// the header text with the button's label
|
||||||
events.clicked.listen {
|
events.clicked.listen {
|
||||||
header.replaceText(it.source.label)
|
header.replaceText(it.source.label)
|
||||||
header.requestRedraw()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,12 +70,14 @@ class P : TextElement(ElementType("p"))
|
|||||||
abstract class TextElement(et: ElementType) : Element(et) {
|
abstract class TextElement(et: ElementType) : Element(et) {
|
||||||
fun text(text: String) {
|
fun text(text: String) {
|
||||||
append(TextNode(text))
|
append(TextNode(text))
|
||||||
|
requestRedraw()
|
||||||
}
|
}
|
||||||
fun replaceText(text : String) {
|
fun replaceText(text : String) {
|
||||||
if (children.isEmpty()) {
|
if (children.isEmpty()) {
|
||||||
text(text)
|
text(text)
|
||||||
} else {
|
} else {
|
||||||
(children.first() as? TextNode)?.text = text
|
(children.first() as? TextNode)?.text = text
|
||||||
|
requestRedraw()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user