JSMenuItem
Last updated
Was this helpful?
Last updated
Was this helpful?
The JSMenuItem
scripting wrapper provides functionality for managing menu items in a Servoy application. It supports configuration and interaction through constants, properties, and methods, enabling dynamic customization of menu behavior and appearance. ## Functionality
Constants such as ENABLED
and VIEWABLE
control security flags, determining whether menu items are accessible or visible. Properties like callbackArguments
, enabled
, iconStyleClass
, itemID
, menuText
, styleClass
, and tooltipText
allow precise customization of menu item attributes, including visual styling, text, and state.
The functionality includes methods to manage menu items dynamically. Developers can add new items using methods like addSubMenuItem
, which supports specifying positions, or retrieve existing items through methods such as getSubMenuItem
and getSubMenuItemAt
. Items can also be removed using the removeSubMenuItem
method.
Security and visibility features allow control over menu item behavior. The setSecurityFlags
method, combined with constants like ENABLED
and VIEWABLE
, provides flexibility to set whether a menu item is visible and interactive. Additional methods, such as getEnabledWithSecurity
and getSubMenuItemsWithSecurity
, refine the interaction by considering security constraints.
Properties and additional functionality extend to retrieving extra information, such as through the getExtraProperty
method, and updating the menu item’s appearance and behavior dynamically. These capabilities make JSMenuItem
a versatile tool for creating adaptive and secure menu systems in Servoy applications.
section of this documentation
Constant representing the enabled flag for menu item security.
Constant representing the viewable flag for menu item seurity.
Set/Get the menu item callback arguments (for components that support this)
Set/Get the menu item enabled state
Set/Get the menu item space separated icon style classes
Set/Get the menu item text
The menu name (identifier)
Set/Get the menu space separated styleclases
Set/Get the menu item tooltip text
Adds a new menu item, as last item in the list.
Adds a new menu item, at a specific position.
Gets a menu item by identifier.
Returns custom property value.
Returns an extra property value.
Gets a menu item by identifier.
Gets a menu item by index (0 based).
Returns all the menus items, either created at design time or at runtime, in the order they will show up in user interface.
Removes a menu item from children's list, returns true if element was found an removed
Removes a menu item with given id, returns true if element was found an removed
void
Selects a menu item in user interface
void
Sets a custom property value.
void
Sets an extra property value (property must be present in the component spec).
void
Override the permission data and design data (for enabled flag) and set if a menu item is viewable(visible) and enabled.
Constant representing the enabled flag for menu item security.
Sample
Constant representing the viewable flag for menu item seurity.
Sample
Set/Get the menu item callback arguments (for components that support this)
Sample
Set/Get the menu item enabled state
Sample
Set/Get the menu item space separated icon style classes
Sample
Set/Get the menu item text
Sample
The menu name (identifier)
Set/Get the menu space separated styleclases
Sample
Set/Get the menu item tooltip text
Sample
Adds a new menu item, as last item in the list.
Parameters
Sample
Adds a new menu item, at a specific position.
Parameters
Sample
Gets a menu item by identifier. Also searches for nested elements. Returns null if not found.
Parameters
Sample
Returns custom property value. Custom properties can be defined on each Menu.
Parameters
Sample
Returns an extra property value.
Parameters
Sample
Gets a menu item by identifier. Returns null if not found.
Parameters
Sample
Gets a menu item by index (0 based). Returns null if not found.
Parameters
Sample
Returns all the menus items, either created at design time or at runtime, in the order they will show up in user interface.
Sample
Removes a menu item from children's list, returns true if element was found an removed
Parameters
Sample
Removes a menu item with given id, returns true if element was found an removed
Parameters
Sample
Selects a menu item in user interface
Parameters
Returns: void
Sample
Sets a custom property value. Custom properties can be defined on each Menu.
Parameters
Returns: void
Sample
Sets an extra property value (property must be present in the component spec).
Parameters
Returns: void
Sample
Override the permission data and design data (for enabled flag) and set if a menu item is viewable(visible) and enabled.
Parameters
Returns: void
Sample
Type
Type
Type The callback arguments of the menu item for supported components.
Type The enabled state of the menu item.
Type The space-separated icon style classes of the menu item.
Type The text of the menu item.
Type the name (identifier) of the menu
Type The space-separated style classes applied to the menu.
Type The tooltip text of the menu item.
id the menu item identifier
Returns: The newly added menu item.
id the menu item identifier
index the index position in list (0 based)
Returns: The newly added menu item at the specified index.
id the menu item identifier
Returns: The menu item with the specified identifier, including nested items, or null if not found.
{String} propertyName - The name of the property to retrieve the value for.
Returns: The value of the specified custom property, or null if not found.
Returns: Returns whether the menu item is enabled with security constraints applied.
{String} propertyName - The name of the property to retrieve the value for.
Returns: The value of the specified extra property, or null if not found.
id the menu item identifier
Returns: The menu item with the specified identifier, or null if not found.
index the menu item index among its sibblings
Returns: The menu item at the specified index, or null if the index is out of bounds.
Returns: An array of all menu items in this menu, in the order they appear in the user interface.
Returns: An array of menu items that have the security flag set to "viewable."
Returns: the selectedItem
menuItem the menu item to be removed
Returns: True if the specified menu item was removed; false otherwise.
id the menu item identifier
Returns: True if a menu item with the specified identifier was removed; false otherwise.
menuItem the menu item to be selected
{String} propertyName - The name of the property to set.
{Object} value - The value to assign to the specified property.
{String} propertyName - The name of the property to set.
{Object} value - The value to assign to the specified property.
flags either 0 or a combination of JSMenuItem.VIEWABLE and JSMenuItem.ENABLED