Skip to content

Commit 0ecb75d

Browse files
committed
implement button
1 parent e19d3b0 commit 0ecb75d

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

lib/ui/core.jsx

+42
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,48 @@ class Label extends View {
531531

532532
class Button extends Control {
533533

534+
// FIXME KAZUHO circular reference
535+
var _node = web.dom.document.createElement("INPUT") as web.HTMLInputElement;
536+
537+
function constructor() {
538+
this._node.type = "button";
539+
}
540+
541+
function constructor(label : string, handler : function(: web.Event) : void) {
542+
this();
543+
this.setLabel(label);
544+
this.setHandler(handler);
545+
}
546+
547+
function setLabel(label : string) : Button {
548+
this._node.value = label;
549+
return this;
550+
}
551+
552+
function getLabel() : string {
553+
return this._node.value;
554+
}
555+
556+
function setHandler(handler : function (: web.Event) : void) : Button {
557+
this._node.onclick = handler;
558+
return this;
559+
}
560+
561+
function getHandler() : function (: web.Event) : void {
562+
return this._node.onclick;
563+
}
564+
565+
override function _toElement() : web.HTMLElement {
566+
var element = super._toElement(); // <div>
567+
568+
element.appendChild(this._node);
569+
570+
var style = this._node.style;
571+
style.width = "100%";
572+
573+
return element;
574+
}
575+
534576
}
535577

536578
class TextField extends Control {

0 commit comments

Comments
 (0)