UNPKG

@launchmenu/core

Version:

An environment for visual keyboard controlled applets

76 lines 2.85 kB
import { IIOContext } from "../../context/_types/IIOContext"; import { IMenu } from "./_types/IMenu"; import { Field, IDataHook } from "model-react"; import { IMenuItem } from "../items/_types/IMenuItem"; import { IMenuCategoryData } from "./_types/IMenuCategoryData"; /** * An abstract menu class that doesn't deal with item management itself */ export declare abstract class AbstractMenu implements IMenu { protected context: IIOContext; protected destroyed: Field<boolean>; protected cursor: Field<IMenuItem | null>; protected selected: Field<IMenuItem[]>; /** * Creates a new abstract menu * @param context The context that menu items can use */ constructor(context: IIOContext); /** * Retrieves the IOContext that's associated with this menu * @returns The context */ getContext(): IIOContext; /** * Retrieves all items in the menu * @param hook The hook to subscribe to changes * @returns All items including category items in the correct sequence */ abstract getItems(hook?: IDataHook): IMenuItem[]; /** * Retrieves all categories of the menu * @param hook The hook to subscribe to changes * @returns All categories and the items that belong to those categories, in the correct sequence */ abstract getCategories(hook?: IDataHook): IMenuCategoryData[]; /** * Selects or deselects the given item * @param item The item to select or deselect * @param selected Whether to select or deselect */ setSelected(item: IMenuItem, selected?: boolean): void; /** * Selects an item to be the cursor * @param item The new cursor */ setCursor(item: IMenuItem | null): void; /** * Retrieves the currently selected items of the menu * @param hook The hook to subscribe to changes * @returns The selected menu items */ getSelected(hook?: IDataHook): IMenuItem[]; /** * Retrieves the item that's currently at the cursor of the menu * @param hook The hook to subscribe to changes * @returns The cursor item */ getCursor(hook?: IDataHook): IMenuItem | null; /** * Retrieves all the selected items including the cursor * @param hook The hook to subscribe to changes * @returns The selected items including the cursor */ getAllSelected(hook?: IDataHook): IMenuItem[]; /** * Destroys the menu, making sure that all items are unselected */ destroy(): boolean; /** * Retrieves whether the menu has been destroyed * @param hook The hook to subscribe to changes * @returns Whether the menu was destroyed */ isDestroyed(hook?: IDataHook): boolean; } //# sourceMappingURL=AbstractMenu.d.ts.map