mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-23 10:07:35 +00:00
Imagine now popmenu might get populated
This commit is contained in:
parent
b31042a216
commit
02cbf94fe8
1 changed files with 32 additions and 3 deletions
|
|
@ -1,15 +1,44 @@
|
|||
import BaseObject from "./BaseObject";
|
||||
import { assume } from "../utils";
|
||||
|
||||
type MenuItem =
|
||||
| {
|
||||
type: "item";
|
||||
text: string;
|
||||
id: number;
|
||||
checked: boolean;
|
||||
disabled: boolean;
|
||||
}
|
||||
| { type: "separator" };
|
||||
|
||||
export default class PopupMenu extends BaseObject {
|
||||
_items: MenuItem[] = [];
|
||||
addcommand(
|
||||
cmdText: string,
|
||||
cmd_id: number,
|
||||
checked: boolean,
|
||||
disabled: boolean
|
||||
) {}
|
||||
addseparator() {}
|
||||
) {
|
||||
this._items.push({
|
||||
type: "item",
|
||||
text: cmdText,
|
||||
id: cmd_id,
|
||||
checked,
|
||||
disabled,
|
||||
});
|
||||
}
|
||||
addseparator() {
|
||||
this._items.push({ type: "separator" });
|
||||
}
|
||||
checkcommand(cmd_id: number, check: boolean) {
|
||||
// TODO
|
||||
const item = this._items.find((item) => {
|
||||
return item.type === "item" && item.id === cmd_id;
|
||||
});
|
||||
assume(item != null, `Could not find item with id "${cmd_id}"`);
|
||||
if (item.type !== "item") {
|
||||
throw new Error("Expected item to be an item.");
|
||||
}
|
||||
item.checked = check;
|
||||
}
|
||||
/*
|
||||
extern PopupMenu.addSubMenu(PopupMenu submenu, String submenutext);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue