2019-08-20 04:56:40 +08:00
|
|
|
import { create_el } from "./dom";
|
|
|
|
import { View } from "./View";
|
|
|
|
import "./Button.css";
|
2019-08-20 21:02:58 +08:00
|
|
|
import { Observable } from "../observable/Observable";
|
2019-08-20 05:49:40 +08:00
|
|
|
|
2019-08-20 04:56:40 +08:00
|
|
|
export class Button extends View {
|
|
|
|
element: HTMLButtonElement = create_el("button", "core_Button");
|
|
|
|
|
|
|
|
constructor(text: string) {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.element.textContent = text;
|
2019-08-20 05:49:40 +08:00
|
|
|
|
2019-08-20 21:02:58 +08:00
|
|
|
this.element.onclick = (e: MouseEvent) => this.click.fire(e, undefined);
|
2019-08-20 04:56:40 +08:00
|
|
|
}
|
2019-08-20 05:49:40 +08:00
|
|
|
|
2019-08-20 21:02:58 +08:00
|
|
|
click = new Observable<MouseEvent>();
|
2019-08-20 04:56:40 +08:00
|
|
|
}
|