Yureka LogoDocs

Context Menu

OSSIM provides a global context menu system for right-click interactions anywhere in the OS, including the desktop surface and within applications.

Showing a Context Menu

From C++

UContextMenuSubsystem* CM = GameInstance->GetSubsystem<UContextMenuSubsystem>();

TArray<FContextMenuItem> Items;

FContextMenuItem OpenItem;
OpenItem.Label = FText::FromString("Open");
OpenItem.OnSelected.BindLambda([]() { /* handle open */ });
Items.Add(OpenItem);

Items.Add(FContextMenuItem::Separator());

FContextMenuItem DeleteItem;
DeleteItem.Label = FText::FromString("Delete");
DeleteItem.OnSelected.BindLambda([]() { /* handle delete */ });
Items.Add(DeleteItem);

CM->ShowContextMenu(MousePosition, Items);

Context Menu Item (FContextMenuItem)

FieldTypeDescription
LabelFTextDisplay text for the menu item
IconUTexture2D*Optional icon
OnSelectedFOnContextMenuItemSelectedDelegate fired when clicked
bIsEnabledboolWhether the item is clickable (default: true)
bIsSeparatorboolRender as a separator line (default: false)

Static helper: FContextMenuItem::Separator() creates a separator item.

Subsystem API

UContextMenuSubsystem

MethodDescription
ShowContextMenu(FVector2D, TArray<FContextMenuItem>)Display menu at viewport position (Z-order: 9999)
HideContextMenu()Dismiss the active menu
IsMenuOpen()Query whether a menu is currently visible
Set/GetContextMenuClass()Configure the widget class used for menus

Delegate: OnRequestCloseAllMenus() (dynamic/BP) — Broadcast to dismiss all open menus.

Widget Implementation

UContextMenuWidget

  • PopulateMenu(Items[]) — Builds menu item rows.
  • SetPosition(Pos) — Positions the menu at screen coordinates.
  • Auto-dismisses on focus loss or mouse leave.

UContextMenuItemWidget

  • Setup(FContextMenuItem) — Configures display and click handler.
  • OnButtonClicked → invokes OnSelected delegate.

Desktop Integration

The UDesktopSurfaceWidget provides a built-in desktop right-click menu with:

  • "Change Wallpaper" — Opens wallpaper selection.
  • "Open Desktop in Explorer" — Launches File Explorer at the user's desktop path.