UIContextMenu Class
Definition
Namespace: Brine2D.UI
Right-click context menu rendered as a canvas-managed overlay. Add items with AddItem\(string, bool\) and separators with AddSeparator(). Show via ShowContextMenu\(UIContextMenu, Vector2\); it closes when an item is selected, a click lands outside, or Escape is pressed.
Inheritance System.Object → UIContextMenu
| Properties | |
|---|---|
| BackgroundColor | Background fill color of the menu panel. |
| BorderColor | Border color drawn around the menu panel. |
| DisabledTextColor | Text color for disabled items. |
| Font | Optional font for item labels. Null = renderer default. |
| Height | Total height of the menu in pixels, computed from the current item list. |
| HoverColor | Background color used when the pointer is over an enabled item. |
| ItemCount | Returns the number of items \(including separators\). |
| ItemHeight | Height of each non-separator item in pixels. |
| Position | Screen-space position of the top-left corner. Set by ShowContextMenu\(UIContextMenu, Vector2\). |
| SeparatorColor | Color of separator lines. |
| SeparatorHeight | Height of separator items in pixels. |
| TextColor | Text color for enabled items. |
| TextPadding | Horizontal text padding from the left edge of menu items. |
| Width | Width of the menu in pixels. Height is computed automatically from the item count. |
| Methods | |
|---|---|
| AddItem\(string, bool\) | Adds a labeled item. Use enabled to grey it out without removing it. Returns this for fluent chaining. |
| AddSeparator() | Adds a visual separator line. Returns this for fluent chaining. |
| Contains\(Vector2\) | Returns true when screenPosition lies within the menu bounds. |
| GetItemLabel\(int\) | Returns the label of the item at index. Separators return an empty string. |
| HitTestItem\(Vector2\) | Returns the index of the item whose row contains screenPosition, or -1 if the position is outside the menu. |
| IsItemEnabled\(int\) | Returns whether the item at index is enabled. |
| IsItemSeparator\(int\) | Returns whether the item at index is a separator. |
| Events | |
|---|---|
| OnClosed | Fired when the menu is closed \(item selected, outside click, or Escape\). |
| OnItemSelected | Fired when an enabled item is selected. Parameters are the zero-based item index \(separators are counted\) and the item label. |