UniTextContextMenu
Context menu you lay out yourself in Unity UI: a panel and the objects its items show on, styled and localized however you like. Each of its Items binds an object of the layout to the command it runs; the menu shows the objects of the commands the field offers and runs a command when its object is clicked. It draws nothing itself, and one menu serves every field that presents it — a click acts on the field that showed it last.
Remarks
Commands) shows on the first item whose command matches it; while it does not apply, the item hides its object or shows it disabled (ContextMenuItem.WhenUnavailable). A Toggle shows whether the command's effect is on (TextMenuEntry.IsActive), and an item's ContextMenuItem.Label receives the command's title. The objects keep their places in the layout; an item whose command the field does not offer is hidden. The commands no item matches — added to the field or the project, or the Android apps of SystemTextActions — show on copies of the object of the first item without a command, right after it in the field's order. That object stays hidden; without such an item those commands are not shown. A menu that shows nothing stays hidden. A menu touch opened sits centred above the selection and its handles, or below them where only that fits, and leaves the rest of the screen to the field. A menu a mouse or pen opened hangs from the pointer, and one the keyboard opened from the caret or the selection with its first item highlighted; either turns left or up where it would leave the screen — the keyboard's up above the caret's line — closes on a press anywhere outside it and takes the field's keys (HandleKey). Every menu stays inside the canvas and the screen's safe area, and above a soft keyboard. Visibility is driven through the CanvasGroup, and the required FocusGuard keeps the field focused while the user presses an item.public override void Show(in TextMenuPlacement placement, IReadOnlyList<TextMenuEntry> entries, Action<int> invoke)Shows entries at placement and records invoke as the single receiver of invoked entries until the next Show replaces it or Hide clears it — a menu shared across fields always reports to the field that showed it last. A disabled entry (TextMenuEntry.IsEnabled) shows disabled or not at all and is never invoked; a menu left with nothing to show hides.
public override void HandleKey(NativeKeyCode key, NativeModifiers modifiers)Moves the keyboard highlight through the items that can run, in the layout's order — the arrows step and wrap, Home and End jump to the ends — and runs the highlighted item on Enter; other keys do nothing. The highlight shows through the hover state of the Selectables inside the highlighted object.
