Menu
- class omni.ui.Menu
Bases:
Stack
,MenuHelper
The Menu class provides a menu widget for use in menu bars, context menus, and other popup menus. It can be either a pull-down menu in a menu bar or a standalone context menu. Pull-down menus are shown by the menu bar when the user clicks on the respective item. Context menus are usually invoked by some special keyboard key or by right-clicking.
Methods
__init__
(self[, text])Construct Menu.
call_on_build_fn
(self)Called to re-create new children.
Return the menu that is currently shown.
has_on_build_fn
(self)Called to re-create new children.
hide
(self)Close the menu window.
invalidate
(self)Make Menu dirty so onBuild will be executed to replace the children.
set_on_build_fn
(self, fn)Called to re-create new children.
set_shown_changed_fn
(self, fn)If the pulldown menu is shown on the screen.
set_teared_changed_fn
(self, fn)If the window is teared off.
show
(self)Create a popup window and show the menu in it.
show_at
(self, arg0, arg1)Create a popup window and show the menu in it.
tear_at
(self, arg0, arg1)Create a popup window and show the menu in it.
Attributes
If the pulldown menu is shown on the screen.
The ability to tear the window off.
If the window is teared off.
- __init__(self: omni.ui._ui.Menu, text: str = '', **kwargs) → None
Construct Menu.
### Arguments:
- `text :`
The text for the menu.
- `kwargsdict`
See below
### Keyword Arguments:
- `tearablebool`
The ability to tear the window off.
- `shown_changed_fn`
If the pulldown menu is shown on the screen.
- `teared_changed_fn`
If the window is teared off.
- `on_build_fn`
Called to re-create new children.
- `textstr`
This property holds the menu’s text.
- `hotkey_textstr`
This property holds the menu’s hotkey text.
- `checkablebool`
This property holds whether this menu item is checkable. A checkable item is one which has an on/off state.
- `hide_on_clickbool`
Hide or keep the window when the user clicked this item.
- `delegateMenuDelegate`
The delegate that generates a widget per menu item.
- `triggered_fnvoid`
Sets the function that is called when an action is activated by the user; for example, when the user clicks a menu option, or presses an action’s shortcut key combination.
- `direction`
This type is used to determine the direction of the layout. If the Stack’s orientation is eLeftToRight the widgets are placed in a horizontal row, from left to right. If the Stack’s orientation is eRightToLeft the widgets are placed in a horizontal row, from right to left. If the Stack’s orientation is eTopToBottom, the widgets are placed in a vertical column, from top to bottom. If the Stack’s orientation is eBottomToTop, the widgets are placed in a vertical column, from bottom to top. If the Stack’s orientation is eBackToFront, the widgets are placed sorted in a Z-order in top right corner. If the Stack’s orientation is eFrontToBack, the widgets are placed sorted in a Z-order in top right corner, the first widget goes to front.
- `content_clipping`
Determines if the child widgets should be clipped by the rectangle of this Stack.
- `spacing`
Sets a non-stretchable space in pixels between child items of this layout.
- `send_mouse_events_to_back`
When children of a Z-based stack overlap mouse events are normally sent to the topmost one. Setting this property true will invert that behavior, sending mouse events to the bottom-most child.
- `widthui.Length`
This property holds the width of the widget relative to its parent. Do not use this function to find the width of a screen.
- `heightui.Length`
This property holds the height of the widget relative to its parent. Do not use this function to find the height of a screen.
- `namestr`
The name of the widget that user can set.
- `style_type_name_overridestr`
By default, we use typeName to look up the style. But sometimes it’s necessary to use a custom name. For example, when a widget is a part of another widget. (Label is a part of Button) This property can override the name to use in style.
- `identifierstr`
An optional identifier of the widget we can use to refer to it in queries.
- `visiblebool`
This property holds whether the widget is visible.
- `visibleMinfloat`
If the current zoom factor and DPI is less than this value, the widget is not visible.
- `visibleMaxfloat`
If the current zoom factor and DPI is bigger than this value, the widget is not visible.
- `tooltipstr`
Set a basic tooltip for the widget, this will simply be a Label, it will follow the Tooltip style
- `tooltip_fnCallable`
Set dynamic tooltip that will be created dynamiclly the first time it is needed. the function is called inside a ui.Frame scope that the widget will be parented correctly.
- `tooltip_offset_xfloat`
Set the X tooltip offset in points. In a normal state, the tooltip position is linked to the mouse position. If the tooltip offset is non zero, the top left corner of the tooltip is linked to the top left corner of the widget, and this property defines the relative position the tooltip should be shown.
- `tooltip_offset_yfloat`
Set the Y tooltip offset in points. In a normal state, the tooltip position is linked to the mouse position. If the tooltip offset is non zero, the top left corner of the tooltip is linked to the top left corner of the widget, and this property defines the relative position the tooltip should be shown.
- `enabledbool`
This property holds whether the widget is enabled. In general an enabled widget handles keyboard and mouse events; a disabled widget does not. And widgets display themselves differently when they are disabled.
- `selectedbool`
This property holds a flag that specifies the widget has to use eSelected state of the style.
- `checkedbool`
This property holds a flag that specifies the widget has to use eChecked state of the style. It’s on the Widget level because the button can have sub-widgets that are also should be checked.
- `draggingbool`
This property holds if the widget is being dragged.
- `opaque_for_mouse_eventsbool`
If the widgets has callback functions it will by default not capture the events if it is the top most widget and setup this option to true, so they don’t get routed to the child widgets either
- `skip_draw_when_clippedbool`
The flag that specifies if it’s necessary to bypass the whole draw cycle if the bounding box is clipped with a scrolling frame. It’s needed to avoid the limitation of 65535 primitives in a single draw list.
- `mouse_moved_fnCallable`
Sets the function that will be called when the user moves the mouse inside the widget. Mouse move events only occur if a mouse button is pressed while the mouse is being moved. void onMouseMoved(float x, float y, int32_t modifier)
- `mouse_pressed_fnCallable`
Sets the function that will be called when the user presses the mouse button inside the widget. The function should be like this: void onMousePressed(float x, float y, int32_t button, carb::input::KeyboardModifierFlags modifier) Where ‘button’ is the number of the mouse button pressed. ‘modifier’ is the flag for the keyboard modifier key.
- `mouse_released_fnCallable`
Sets the function that will be called when the user releases the mouse button if this button was pressed inside the widget. void onMouseReleased(float x, float y, int32_t button, carb::input::KeyboardModifierFlags modifier)
- `mouse_double_clicked_fnCallable`
Sets the function that will be called when the user presses the mouse button twice inside the widget. The function specification is the same as in setMousePressedFn. void onMouseDoubleClicked(float x, float y, int32_t button, carb::input::KeyboardModifierFlags modifier)
- `mouse_wheel_fnCallable`
Sets the function that will be called when the user uses mouse wheel on the focused window. The function specification is the same as in setMousePressedFn. void onMouseWheel(float x, float y, carb::input::KeyboardModifierFlags modifier)
- `mouse_hovered_fnCallable`
Sets the function that will be called when the user use mouse enter/leave on the focused window. function specification is the same as in setMouseHovedFn. void onMouseHovered(bool hovered)
- `drag_fnCallable`
Specify that this Widget is draggable, and set the callback that is attached to the drag operation.
- `accept_drop_fnCallable`
Specify that this Widget can accept specific drops and set the callback that is called to check if the drop can be accepted.
- `drop_fnCallable`
Specify that this Widget accepts drops and set the callback to the drop operation.
- `computed_content_size_changed_fnCallable`
Called when the size of the widget is changed.
- call_on_build_fn(self: omni.ui._ui.Menu) → None
Called to re-create new children.
- static get_current() → omni.ui._ui.Menu
Return the menu that is currently shown.
- has_on_build_fn(self: omni.ui._ui.Menu) → bool
Called to re-create new children.
- hide(self: omni.ui._ui.Menu) → None
Close the menu window. It only works for pop-up context menu and for teared off menu.
- invalidate(self: omni.ui._ui.Menu) → None
Make Menu dirty so onBuild will be executed to replace the children.
- set_on_build_fn(self: omni.ui._ui.Menu, fn: Callable[[], None]) → None
Called to re-create new children.
- set_shown_changed_fn(self: omni.ui._ui.Menu, fn: Callable[[bool], None]) → None
If the pulldown menu is shown on the screen.
- set_teared_changed_fn(self: omni.ui._ui.Menu, fn: Callable[[bool], None]) → None
If the window is teared off.
- show(self: omni.ui._ui.Menu) → None
Create a popup window and show the menu in it. It’s usually used for context menus that are typically invoked by some special keyboard key or by right-clicking.
- show_at(self: omni.ui._ui.Menu, arg0: float, arg1: float) → None
Create a popup window and show the menu in it. This enable to popup the menu at specific position. X and Y are in points to make it easier to the Python users.
- tear_at(self: omni.ui._ui.Menu, arg0: float, arg1: float) → None
Create a popup window and show the menu in it. This tear the menu at specific position. X and Y are in points to make it easier to the Python users.
- property shown
If the pulldown menu is shown on the screen.
- property tearable
The ability to tear the window off.
- property teared
If the window is teared off.