-
Notifications
You must be signed in to change notification settings - Fork 0
PopupMenu
Home | API by Category | Complete API Index | API Compatibility
| Field | Value |
|---|---|
| Full name | Electron2D.PopupMenu |
| Namespace | Electron2D |
| Kind | class |
| Category | UI and Text |
Displays a temporary menu of command items.
public class Electron2D.PopupMenu : Electron2D.ControlPopupMenu stores labeled items, separators and checkable commands.
It emits both item index and command id when an enabled item is activated.
The 0.1.0 Preview implementation is a Electron2D.Control-based runtime
menu. Native window integration and submenus are outside this task.
This type is not synchronized. Create and mutate popup menus on the main scene thread.
This type is available since Electron2D 0.1.0 Preview.
Electron2D.ControlElectron2D.ItemList
| Member | Kind | Summary |
|---|---|---|
Electron2D.PopupMenu() |
Constructor | Initializes a new instance of the Electron2D.PopupMenu class. |
AddCheckItem(System.String, System.Int32) |
Method | Adds a checkable command item. |
AddIconCheckItem(Electron2D.Texture2D, System.String, System.Int32) |
Method | Adds a checkable command item with an icon. |
AddIconItem(Electron2D.Texture2D, System.String, System.Int32) |
Method | Adds a command item with an icon. |
AddItem(System.String, System.Int32) |
Method | Adds a plain text command item. |
AddSeparator(System.String, System.Int32) |
Method | Adds a separator item. |
Clear() |
Method | Removes every menu item. |
GetItemCount() |
Method | Gets the number of menu items. |
GetItemIcon(System.Int32) |
Method | Gets the icon of an item. |
GetItemId(System.Int32) |
Method | Gets the id stored on an item. |
GetItemText(System.Int32) |
Method | Gets the text of an item. |
IsItemChecked(System.Int32) |
Method | Reports whether an item is checked. |
IsItemDisabled(System.Int32) |
Method | Reports whether an item is disabled. |
IsItemSeparator(System.Int32) |
Method | Reports whether an item is a separator. |
Popup(Electron2D.Rect2) |
Method | Shows this menu inside a rectangle. |
SetItemChecked(System.Int32, System.Boolean) |
Method | Sets whether a checkable item is checked. |
SetItemDisabled(System.Int32, System.Boolean) |
Method | Sets whether an item ignores activation input. |
SetItemIcon(System.Int32, Electron2D.Texture2D) |
Method | Sets the icon of an item. |
SetItemId(System.Int32, System.Int32) |
Method | Sets the id stored on an item. |
SetItemText(System.Int32, System.String) |
Method | Sets the text of an item. |
_Draw() |
Method | Draws the menu rows and labels. |
_GetMinimumSize() |
Method | Gets the minimum size requested by this popup menu. |
_GuiInput(Electron2D.InputEvent) |
Method | Handles GUI input routed to this menu. |
Kind: Constructor
public Electron2D.PopupMenu()Initializes a new instance of the Electron2D.PopupMenu class.
The constructor registers index_pressed and id_pressed
signals and hides the menu until Electron2D.PopupMenu.Popup(Electron2D.Rect2) is called.
This constructor is not synchronized. Call it from the main scene thread.
This constructor is available since Electron2D 0.1.0 Preview.
Electron2D.PopupMenu
Kind: Method
public System.Void AddCheckItem(System.String, System.Int32)(System.String label, System.Int32 id)Adds a checkable command item.
The item starts unchecked. Use Electron2D.PopupMenu.SetItemChecked(System.Int32,System.Boolean) to change
the checked state.
-
label: The item label. -
id: The command id emitted byid_pressed.
-
System.ArgumentNullException: Thrown whenlabelisnull.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.PopupMenu.AddIconCheckItem(Electron2D.Texture2D,System.String,System.Int32)
Kind: Method
public System.Void AddIconCheckItem(Electron2D.Texture2D, System.String, System.Int32)(Electron2D.Texture2D texture, System.String label, System.Int32 id)Adds a checkable command item with an icon.
The item starts unchecked and can be toggled by
Electron2D.PopupMenu.SetItemChecked(System.Int32,System.Boolean).
-
texture: The icon texture. -
label: The item label. -
id: The command id emitted byid_pressed.
-
System.ArgumentNullException: Thrown whentextureorlabelisnull.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.PopupMenu.AddCheckItem(System.String,System.Int32)
Kind: Method
public System.Void AddIconItem(Electron2D.Texture2D, System.String, System.Int32)(Electron2D.Texture2D texture, System.String label, System.Int32 id)Adds a command item with an icon.
Icon drawing uses the existing texture draw path when a renderer consumes the generated canvas commands.
-
texture: The icon texture. -
label: The item label. -
id: The command id emitted byid_pressed.
-
System.ArgumentNullException: Thrown whentextureorlabelisnull.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.PopupMenu.AddItem(System.String,System.Int32)
Kind: Method
public System.Void AddItem(System.String, System.Int32)(System.String label, System.Int32 id)Adds a plain text command item.
Passing -1 for id stores the current item
index as the command id.
-
label: The item label. -
id: The command id emitted byid_pressed.
-
System.ArgumentNullException: Thrown whenlabelisnull.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.PopupMenu.AddIconItem(Electron2D.Texture2D,System.String,System.Int32)
Kind: Method
public System.Void AddSeparator(System.String, System.Int32)(System.String label, System.Int32 id)Adds a separator item.
Separators cannot be activated and do not emit press signals.
-
label: The optional separator label. -
id: The separator id stored for metadata queries.
-
System.ArgumentNullException: Thrown whenlabelisnull.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.PopupMenu.IsItemSeparator(System.Int32)
Kind: Method
public System.Void Clear()()Removes every menu item.
Visibility and registered signals are not changed.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.PopupMenu.AddItem(System.String,System.Int32)
Kind: Method
public System.Int32 GetItemCount()()Gets the number of menu items.
Separators are included in the count.
The current menu item count.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.PopupMenu.Clear
Kind: Method
public Electron2D.Texture2D GetItemIcon(System.Int32)(System.Int32 index)Gets the icon of an item.
Use Electron2D.PopupMenu.SetItemIcon(System.Int32,Electron2D.Texture2D) to replace the icon.
-
index: The item index.
The item icon, or null when none is set.
-
System.ArgumentOutOfRangeException: Thrown whenindexis outside the item list.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.PopupMenu.SetItemIcon(System.Int32,Electron2D.Texture2D)
Kind: Method
public System.Int32 GetItemId(System.Int32)(System.Int32 index)Gets the id stored on an item.
The id is emitted through id_pressed when the item activates.
-
index: The item index.
The item id.
-
System.ArgumentOutOfRangeException: Thrown whenindexis outside the item list.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.PopupMenu.SetItemId(System.Int32,System.Int32)
Kind: Method
public System.String GetItemText(System.Int32)(System.Int32 index)Gets the text of an item.
The returned string is never null.
-
index: The item index.
The item text.
-
System.ArgumentOutOfRangeException: Thrown whenindexis outside the item list.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.PopupMenu.SetItemText(System.Int32,System.String)
Kind: Method
public System.Boolean IsItemChecked(System.Int32)(System.Int32 index)Reports whether an item is checked.
Checked state is independent from activation.
-
index: The item index.
true when the item is checked; otherwise, false.
-
System.ArgumentOutOfRangeException: Thrown whenindexis outside the item list.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.PopupMenu.SetItemChecked(System.Int32,System.Boolean)
Kind: Method
public System.Boolean IsItemDisabled(System.Int32)(System.Int32 index)Reports whether an item is disabled.
Disabled items cannot emit press signals from user input.
-
index: The item index.
true when the item is disabled; otherwise, false.
-
System.ArgumentOutOfRangeException: Thrown whenindexis outside the item list.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.PopupMenu.SetItemDisabled(System.Int32,System.Boolean)
Kind: Method
public System.Boolean IsItemSeparator(System.Int32)(System.Int32 index)Reports whether an item is a separator.
Separators cannot be activated.
-
index: The item index.
true when the item is a separator; otherwise, false.
-
System.ArgumentOutOfRangeException: Thrown whenindexis outside the item list.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.PopupMenu.AddSeparator(System.String,System.Int32)
Kind: Method
public System.Void Popup(Electron2D.Rect2)(Electron2D.Rect2 bounds)Shows this menu inside a rectangle.
The menu becomes visible and grabs focus when it is already inside a scene tree.
-
bounds: The global rectangle used for the menu position and size.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.CanvasItem.Hide
Kind: Method
public System.Void SetItemChecked(System.Int32, System.Boolean)(System.Int32 index, System.Boolean checked)Sets whether a checkable item is checked.
The value can be stored on plain items too, but only checkable items draw a check indicator.
-
index: The item index. -
checked:trueto mark the item checked; otherwise,false.
-
System.ArgumentOutOfRangeException: Thrown whenindexis outside the item list.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.PopupMenu.IsItemChecked(System.Int32)
Kind: Method
public System.Void SetItemDisabled(System.Int32, System.Boolean)(System.Int32 index, System.Boolean disabled)Sets whether an item ignores activation input.
Disabled items still occupy rows and can be inspected through metadata methods.
-
index: The item index. -
disabled:trueto disable the item; otherwise,false.
-
System.ArgumentOutOfRangeException: Thrown whenindexis outside the item list.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.PopupMenu.IsItemDisabled(System.Int32)
Kind: Method
public System.Void SetItemIcon(System.Int32, Electron2D.Texture2D)(System.Int32 index, Electron2D.Texture2D icon)Sets the icon of an item.
Separators may also store icons, although the preview drawing path does not render separator icons.
-
index: The item index. -
icon: The icon texture, ornullto clear it.
-
System.ArgumentOutOfRangeException: Thrown whenindexis outside the item list.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.PopupMenu.GetItemIcon(System.Int32)
Kind: Method
public System.Void SetItemId(System.Int32, System.Int32)(System.Int32 index, System.Int32 id)Sets the id stored on an item.
Item ids are independent from item order.
-
index: The item index. -
id: The id emitted byid_pressed.
-
System.ArgumentOutOfRangeException: Thrown whenindexis outside the item list.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.PopupMenu.GetItemId(System.Int32)
Kind: Method
public System.Void SetItemText(System.Int32, System.String)(System.Int32 index, System.String text)Sets the text of an item.
Assigning text queues a redraw.
-
index: The item index. -
text: The new item text.
-
System.ArgumentOutOfRangeException: Thrown whenindexis outside the item list. -
System.ArgumentNullException: Thrown whentextisnull.
This method is not synchronized. Call it on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.PopupMenu.GetItemText(System.Int32)
Kind: Method
public System.Void _Draw()()Draws the menu rows and labels.
Text drawing is skipped when no theme font is available.
This callback is invoked on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.CanvasItem.DrawRect(Electron2D.Rect2,Electron2D.Color,System.Boolean,System.Single,System.Boolean)
Kind: Method
public Electron2D.Vector2 _GetMinimumSize()()Gets the minimum size requested by this popup menu.
The minimum width is fixed in the preview implementation.
A conservative menu size based on item count.
This callback is invoked on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.Control.GetMinimumSize
Kind: Method
public System.Void _GuiInput(Electron2D.InputEvent)(Electron2D.InputEvent inputEvent)Handles GUI input routed to this menu.
Mouse and touch press activate the row under the pointer. Keyboard activation currently uses the first enabled item.
-
inputEvent: The input event delivered by the viewport.
This callback is invoked on the main scene thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.Control._GuiInput(Electron2D.InputEvent)
Electron2D 0.1.0 Preview API reference. Generated from 175 public runtime types.