UNPKG

@playcanvas/pcui

Version:

User interface component library for the web

127 lines (126 loc) 3.85 kB
import { Observer } from '@playcanvas/observer'; import { Container, ContainerArgs } from '../Container'; import { Element, IBindable } from '../Element'; import { Label } from '../Label'; /** * The arguments for the {@link MenuItem} constructor. */ interface MenuItemArgs extends ContainerArgs { value?: any; /** * Whether the MenuItem has any child MenuItems. */ hasChildren?: boolean; /** * Sets the text shown on the MenuItem. */ text?: string; /** * Sets the CSS code for an icon for the MenuItem. e.g. 'E401' (notice we omit the '\\' character). */ icon?: string; /** * Sets the parent Menu Element. */ menu?: any; /** * Sets the function called when we select the MenuItem. */ onSelect?: (evt?: MouseEvent) => void; /** * Sets the function that determines whether the MenuItem should be enabled when the Menu is shown. */ onIsEnabled?: () => boolean; /** * Sets the function that determines whether the MenuItem should be visible when the Menu is shown. */ onIsVisible?: () => boolean; /** * An array of MenuItem constructor data. If defined then child MenuItems will be created and added to the MenuItem. */ items?: Array<MenuItemArgs>; } /** * The MenuItem is a selectable option that is appended to a {@link Menu}. A MenuItem can also * contain child MenuItems (by appending them to the MenuItem). This can be useful to show nested * Menus. */ declare class MenuItem extends Container implements IBindable { /** * The function called when the MenuItem is selected. */ onSelect: (evt?: MouseEvent) => void; /** * The function that determines whether the MenuItem should be enabled when the Menu is shown. */ onIsEnabled: () => boolean; /** * The function that determines whether the MenuItem should be visible when the Menu is shown. */ onIsVisible: () => boolean; protected _containerContent: Container; protected _numChildren: number; protected _icon: string; protected _labelText: Label; protected _containerItems: Container; protected _menu: any; protected _renderChanges: boolean; /** * Creates a new MenuItem. * * @param args - The arguments. */ constructor(args?: Readonly<MenuItemArgs>); destroy(): void; protected _onAppendChild(element: Element): void; protected _onRemoveChild(element: Element): void; protected _onClickMenuItem: (evt: MouseEvent) => void; link(observers: Observer | Observer[], paths: string | string[]): void; unlink(): void; /** * Selects the MenuItem which also happens automatically when the user clicks on the MenuItem. */ select(): void; /** * Sets the text shown on the MenuItem. */ set text(value: string); /** * Gets the text shown on the MenuItem. */ get text(): string; set value(value: string); get value(): string; set values(values: string[]); /** * Sets the CSS code for an icon for the MenuItem. e.g. 'E401' (notice we omit the '\\' character). */ set icon(value: string); /** * Gets the CSS code for an icon for the MenuItem. */ get icon(): string; /** * Sets the binding for the MenuItem label. */ set binding(value: import("../..").BindingBase); /** * Gets the binding for the MenuItem label. */ get binding(): import("../..").BindingBase; /** * Sets the menu. */ set menu(value: any); /** * Gets the menu. */ get menu(): any; /** * Returns whether the MenuItem has children. */ get hasChildren(): boolean; set renderChanges(value: boolean); get renderChanges(): boolean; } export { MenuItem, MenuItemArgs };