import { types } from "assets/types.js"; import { widget } from "interface/widget.js"; class push extends widget { #is_pressed; constructor(name = undefined, submit = false) { types.check_boolean(submit); const target = document.createElement("button"); if (submit) { target.type = "submit"; } if (typeof(name) === "string") { target.name = name; } super(target, "push", name); this.#is_pressed = false; this._add_event("mousedown", () => { this.#pressed(); }); this._add_event("mouseup", () => { this.#released(); }); this._add_event("mouseover", () => { this.#released(); }); } #pressed() { this.#is_pressed = true; } #released() { this.#is_pressed = false; } set icon(target) { if (!(target instanceof icon)) { throw new TypeError("Icon for button must be an icon."); } this._drop_content(); this._append(target); } set text(target) { this._drop_content(); this._content = text; } get is_pressed() { return this.#is_pressed; } } export { push };