Skip to content

ContextMenu

requires layer

A dynamic context menu that can contain anything from menu entries to custom content.

Usage

This component takes 2 parameters: the object and the ContextMenu properties. The object is the object around which the context menu is wrapped. Right clicking this object will result in the context menu opening. This object has to be part of a layer to function, which can be created through topLayerProvider.new.

The original object is returned through the function and is only used to find the closest layer to display the context menu on.

Properties

Color, Variant, AppearanceOverride

Use the Color, Variant and AppearanceOverride properties to style the component.

Available colors are gray. Available variants differ per color and can be viewed in the UI demo below.

The theme data for the component can be found in the Theming section and can be overwritten through AppearanceOverride.

Pass Color and Variant as a string and AppearanceOverride as an optionalColorTable. More information on overrides can be found here.

There is only one color listed as the color does not directly affect the component, but instead only it's menu entries, due to it being registered as their FallbackColor.

Enabled

Whether the context menu can be opened. If set to false while the context menu is open, it will close.

Type

luau

Code block has not loaded. An error may have occurred.

Visible

Whether the context menu is visible. This bypasses the Enabled property.

Type

luau

Code block has not loaded. An error may have occurred.

VisibleLogic

Whenever the context menu is opened via normal means, this function will be called. If it returns false, the context menu will not open. This is useful for defining custom conditions for when the context menu should be opened.

Type

luau

Code block has not loaded. An error may have occurred.

Options

The options that the context menu will display. These are grouped by tables. Each different table has a divider between each other.

Type

luau

Code block has not loaded. An error may have occurred.

Position

The position of the context menu. If this is set, mouse position is no longer taken into account.

Type

luau

Code block has not loaded. An error may have occurred.

StateOutput

A few values that allow you to read and control the state of the context menu.

Explanation of the values:

  • Size: The size of the context menu, in a Vector2.
  • Menu: The menu itself. Can be used to make this menu invisible or read the parent.
  • ResetPosition: If set to true, the context menu will calculate a new position. When the context menu is set to visible, it's position is locked. This unlocks it for a split second to reset it.

Type

luau

Code block has not loaded. An error may have occurred.

Instance Properties

This instance takes all the properties of a Frame. SpecialKeys, such as fusion.Children will also be passed to the instance.

Theming

States

StateDescription
Base

Colors

ColorDescription
Background
Stroke
Text
Shadow

Types

Certain types are reused across different components. To make these types easily accessible, they are available below:

option

luau

Code block has not loaded. An error may have occurred.

menu

luau

Code block has not loaded. An error may have occurred.