Constructor
new ContextMenu()
ContextMenu constructor.
// Usage example:
const menu = new ContextMenu(); // creates new context menu
new MenuItem("Item 1").addTo(menu); // adds menu item to context menu
new MenuItem("Item 2").addTo(menu); // adds menu item to context menu
textfield.contextMenu(menu); // set context menu for text fieldClasses
Members
(readonly) invoker :Object|null
Returns last invoker Object that invoked the popup, or null if no invoker was involved.
- Object |
null
Methods
addChild(component, …data_or_indexopt) → {this}
Adds a child component to this container component. Overrides addChild() method from UIComponent class to add component validation logic.
| Name | Type | Attributes | Description |
|---|---|---|---|
component | Object | UI Component that can be a child of this component. | |
data_or_index | any | <optional> <repeatable> | Argument to pass some extra data (such as Tab Name to add Panel to Tabs), or index at which to insert the child. By default component is added to the end. |
- Type:
- this
addTo(parent) → {ContextMenu}
Adds this ContextMenu to a specified parent component.
| Name | Type | Description |
|---|---|---|
parent | object | A valid component that accepts ContextMenu. |
Returns an instance of this object.
- Type:
- ContextMenu
onPopupEvents(callbackopt, removeopt) → {Array.<function()>|ComboBox}
Registers, unregisters and gets a list of handler functions for the context menu popup events (when the the context menu becomes visible and hidden).
| Name | Type | Attributes | Description |
|---|---|---|---|
callback | function | <optional> | Event handler function that receives a PopupEvent as an argument. Pass |
remove | boolean | <optional> | Set to |
- See
Returns an array of registered handler functions if arguments are omitted, otherwise returns this component instance.
- Type:
- Array.<function()> |
ComboBox
// event Object format:
const e = {
target: object, // The component that triggered the event.
type: string, // `show`, `hide`, `cancel`.
invoker: Object // UI Component that invoked the popup, or `null` if it was invoked programmatically.
x: number, // X position relative to invoker. Only present when invoker is not `null`.
y: number, // Y position relative to invoker. Only present when invoker is not `null`.
screenX: number, // X position relative to default screen.
screenY: number, // Y position relative to default screen.
interactive: boolean, // Indicates if the popup was triggered by user's interaction (not programmatically).
};open(positionopt, invokeropt) → {ContextMenu}
Open the menu with all its parent menus or context menu.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
position | object | <optional> | null | Example: {x: 100, y: 100}. Used to specify position where to open the ContextMenu. If invoker is specified, then position is relative to position of invoker component, otherwise it a screen position. |
invoker | object | <optional> | null | Used to set invoker if the context menu isn't assigned to any object and you want to be able to get invoker by using "invoker" getter. |
Returns this ContextMenu instance.
- Type:
- ContextMenu
remove(childopt, recursiveopt) → {ContextMenu}
Removes this ContextMenu from all parent components or removes a specified child component from this ContextMenu.
| Name | Type | Attributes | Description |
|---|---|---|---|
child | Object | <optional> | Child to be removed. When omitted, this context menu gets removed from all parent components. |
recursive | boolean | <optional> | Indicates whether to also remove all child's descendents. |
Returns an instance of this component.
- Type:
- ContextMenu
child.remove(); // Removes this context menu from it's parent components
child.remove(true); // Removes this context menu from it's parent components and all its descendants recursively
parent.remove(child); // removes child from parent container
parent.remove(child, true); // Removes child from parent container and all of child's descendants recursively