Module MaterialFX

Class MFXContextMenu

All Implemented Interfaces:
MFXStyleablePopup, Styleable, EventTarget, Skinnable

public class MFXContextMenu extends MFXPopup
MFXContextMenu is a special case of MFXPopup. The content is determined by its skin, and also has a userAgentStylesheet to define the default style for all MFXContextMenus.

You can easily manage on what condition to show the popup and where to show it by changing these two properties:

- showConditionProperty(): by default checks if the pressed mouse button was the SECONDARY button

- showActionProperty(): by default calls MFXPopup.show(Node, double, double) with the mouse screen coordinates

The new implementation doesn't allow to change the owner anymore, to keep things simple.

The new implementation allows adding generic separators, not only lines, addSeparator(Node), usually this is a Label to categorize the menu items. The new implementation also allows to disable the popup. The disabled state is used by the default showConditionProperty(), so keep in mind that if you change that the disabled state will be ignored (unless specified by your logic of course).

It is highly suggested using the MFXContextMenu.Builder class to create a context menu.

NOTE that since the content of the context menu is entirely determined by its skin, the MFXPopup.contentProperty() will always be null. As a result methods involving Alignment, HPos or VPos will fail with a NullPointerException.