mapcomplete/UI/Base/CheckBox.ts

33 lines
918 B
TypeScript
Raw Normal View History

2020-07-20 11:30:58 +00:00
import {UIElement} from "../UIElement";
import {UIEventSource} from "../UIEventSource";
2020-07-20 14:57:46 +00:00
import { FilteredLayer } from "../../Logic/FilteredLayer";
2020-07-20 11:30:58 +00:00
export class CheckBox extends UIElement{
2020-07-20 11:37:33 +00:00
private data: UIEventSource<boolean>;
2020-07-20 11:30:58 +00:00
2020-07-22 09:01:25 +00:00
private readonly _data: UIEventSource<boolean>;
private readonly _showEnabled: string|UIElement;
private readonly _showDisabled: string|UIElement;
constructor(data: UIEventSource<boolean>, showEnabled: string|UIElement, showDisabled: string|UIElement) {
2020-07-20 11:30:58 +00:00
super(data);
2020-07-22 09:01:25 +00:00
this._data = data;
this._showEnabled = showEnabled;
this._showDisabled = showDisabled;
this.onClick(() => {
data.setData(!data.data);
})
2020-07-20 11:30:58 +00:00
}
2020-07-22 09:05:04 +00:00
InnerRender(): string {
2020-07-22 09:01:25 +00:00
if (this._data.data) {
return this._showEnabled;
} else {
return this._showDisabled;
}
2020-07-20 11:30:58 +00:00
}
}