diff --git a/src/eterna/ui/ContextMenuDialog.ts b/src/eterna/ui/ContextMenuDialog.ts new file mode 100644 index 000000000..f4459b46d --- /dev/null +++ b/src/eterna/ui/ContextMenuDialog.ts @@ -0,0 +1,30 @@ +import {Point} from 'pixi.js'; +import ContextMenu from './ContextMenu'; +import Dialog from './Dialog'; + +export default class ContextMenuDialog extends Dialog { + constructor(menu: ContextMenu, menuLoc: Point) { + super(); + this._menu = menu; + this._menuLoc = menuLoc; + } + + protected added(): void { + super.added(); + this.addObject(this._menu, this.container); + + this._menu.display.position.copyFrom(this._menuLoc); + this._menu.menuItemSelected.connect(() => this.close()); + } + + protected onBGClicked(): void { + this.close(); + } + + protected get bgAlpha(): number { + return 0; + } + + private readonly _menu: ContextMenu; + private readonly _menuLoc: Point; +}