ContextMenu Class

class NXOpen.MenuBar.ContextMenu

Bases: NXOpen.TransientObject

Represents a Context Menu

New in version NX8.5.0.

Properties

Property Description
NumberOfEntries Returns the number of MenuBar.ContextMenuEntry objects in this menu.

Methods

Method Description
AddMenuButton Adds a menu bar button to the context menu.
AddMenuLabel Adds a label to the context menu.
AddSeparator Adds a separator to the context menu.
AddSubmenu Adds a submenu to the context menu.
Dispose Frees the object from memory.
GetEntry Returns the MenuBar.ContextMenuEntry at the specified index in the menu.
GetEntryWithName Given the name of a menu entry, returns the first MenuBar.ContextMenuEntry in this menu which matches.
GetIndexOfEntry Returns the index of the MenuBar.ContextMenuEntry object within this menu.
GetSubmenu Returns the submenu for the entry at the specified index in the menu.
HasEntryWithName Indicates whether or not this menu contains a MenuBar.ContextMenuEntry which has the given name.
HideEntry Prevents the indicated menu entry from being shown on the menu.
MoveEntry Reorders the menu to move a menu entry to a new position in the list.
SetDefaultEntry Makes a specified menu entry the default for the menu.

Property Detail

NumberOfEntries

ContextMenu.NumberOfEntries

Returns the number of MenuBar.ContextMenuEntry objects in this menu.

-------------------------------------

Getter Method

Signature NumberOfEntries

Returns:
Return type:int

New in version NX8.5.0.

License requirements: None.

Method Detail

AddMenuButton

ContextMenu.AddMenuButton

Adds a menu bar button to the context menu.

Use MenuBar.MenuBarManager.GetButtonFromName() to find the button to add to the menu.

Signature AddMenuButton(button, index)

Parameters:
  • button (NXOpen.MenuBar.MenuButton) – the menu bar button to add to the menu
  • index (int) – position at which to create the new button. Use -1 to add the button to the end of the menu.
Returns:

the new menu entry

Return type:

NXOpen.MenuBar.ContextMenuEntry

New in version NX8.5.0.

License requirements: None.

AddMenuLabel

ContextMenu.AddMenuLabel

Adds a label to the context menu.

Signature AddMenuLabel(label, index)

Parameters:
  • label (str) – label for the label entry
  • index (int) – position at which to create the label entry. Use -1 to add the label to the end of the menu.
Returns:

the new menu entry

Return type:

NXOpen.MenuBar.ContextMenuEntry

New in version NX10.0.0.

License requirements: None.

AddSeparator

ContextMenu.AddSeparator

Adds a separator to the context menu.

Signature AddSeparator(index)

Parameters:index (int) – position at which to create the separator. Use -1 to add the separator to the end of the menu.

New in version NX8.5.0.

License requirements: None.

AddSubmenu

ContextMenu.AddSubmenu

Adds a submenu to the context menu.

Signature AddSubmenu(label, index)

Parameters:
  • label (str) – label for the cascade menu
  • index (int) – position at which to create the sub-menu. Use -1 to add the sub-menu to the end of the menu.
Returns:

the new submenu

Return type:

NXOpen.MenuBar.ContextMenu

New in version NX8.5.0.

License requirements: None.

Dispose

ContextMenu.Dispose

Frees the object from memory.

After this method is called, it is illegal to use the object. In .NET, this method is automatically called when the object is deleted by the garbage collector.

Signature Dispose()

New in version NX8.5.0.

License requirements: None.

GetEntry

ContextMenu.GetEntry

Returns the MenuBar.ContextMenuEntry at the specified index in the menu.

Signature GetEntry(index)

Parameters:index (int) – index of menu entry to return
Returns:the menu entry at this position
Return type:NXOpen.MenuBar.ContextMenuEntry

New in version NX8.5.0.

License requirements: None.

GetEntryWithName

ContextMenu.GetEntryWithName

Given the name of a menu entry, returns the first MenuBar.ContextMenuEntry in this menu which matches.

Signature GetEntryWithName(name)

Parameters:name (str) – name of menu entry to search for
Returns:the menu entry with this name
Return type:NXOpen.MenuBar.ContextMenuEntry

New in version NX8.5.0.

License requirements: None.

GetIndexOfEntry

ContextMenu.GetIndexOfEntry

Returns the index of the MenuBar.ContextMenuEntry object within this menu.

Signature GetIndexOfEntry(entry)

Parameters:entry (NXOpen.MenuBar.ContextMenuEntry) – an entry in the menu
Returns:the index for that menu entry
Return type:int

New in version NX8.5.0.

License requirements: None.

GetSubmenu

ContextMenu.GetSubmenu

Returns the submenu for the entry at the specified index in the menu.

The menu entry at this index must be of type MenuBar.ContextMenuEntryType.Submenu.

Signature GetSubmenu(index)

Parameters:index (int) – index of submenu to return
Returns:the submenu at this position
Return type:NXOpen.MenuBar.ContextMenu

New in version NX8.5.0.

License requirements: None.

HasEntryWithName

ContextMenu.HasEntryWithName

Indicates whether or not this menu contains a MenuBar.ContextMenuEntry which has the given name.

Signature HasEntryWithName(name)

Parameters:name (str) – name of menu entry to search for
Returns:the menu entry with this name
Return type:bool

New in version NX8.5.0.

License requirements: None.

HideEntry

ContextMenu.HideEntry

Prevents the indicated menu entry from being shown on the menu.

Signature HideEntry(entry)

Parameters:entry (NXOpen.MenuBar.ContextMenuEntry) – the menu entry to hide

New in version NX8.5.0.

License requirements: None.

MoveEntry

ContextMenu.MoveEntry

Reorders the menu to move a menu entry to a new position in the list.

Signature MoveEntry(entry, index)

Parameters:

New in version NX8.5.0.

License requirements: None.

SetDefaultEntry

ContextMenu.SetDefaultEntry

Makes a specified menu entry the default for the menu.

This entry will be displayed in bold text on the menu. It will be the action that is performed in response to a double-click event in the UI.

The menu entry must have a type of MenuBar.ContextMenuEntryType.PushButton or MenuBar.ContextMenuEntryType.ToggleButton.

Signature SetDefaultEntry(entry)

Parameters:entry (NXOpen.MenuBar.ContextMenuEntry) – the menu entry to become the default for the menu

New in version NX8.5.0.

License requirements: None.