Skip to content

Commit 0390d0d

Browse files
committed
add Label
1 parent 42d1f1f commit 0390d0d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

lib/ui/core.jsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,35 @@ class Control extends View {
495495
}
496496

497497
class Label extends View {
498+
var _content : web.Node = null;
499+
var _color : Color = Color.DARK_TEXT;
500+
501+
function constructor() {
502+
}
503+
504+
function constructor(text : string) {
505+
this.setText(text);
506+
}
507+
508+
function setText(content : string) : void {
509+
this._content = Util.createTextNode(content);
510+
}
511+
512+
function setText(content : web.Node) : void {
513+
this._content = content;
514+
}
515+
516+
override function _toElement() : web.HTMLElement {
517+
assert this._content != null;
518+
519+
var element = super._toElement(); // <div>
520+
element.appendChild(this._content);
521+
522+
var style = element.style;
523+
style.color = this._color.toStyle();
524+
525+
return element;
526+
}
498527
}
499528

500529
class Button extends Control {

0 commit comments

Comments
 (0)