Context Menus - AngryCarrot789/MemoryEngine360 GitHub Wiki
Advanced Context Menu system
So far, all context menus use the AdvancedContextMenu
class. The menu items have a model-view connection and all the model items are stored in a ContextRegistry
which, when linked to a control, will find or create the AdvancedContextMenu
instance associated with the registry, and it sets it as the control's ContextMenu so that standard context behaviour works.
There's one AdvancedContextMenu
per registry, to help with performance and memory usage.
Context Menus also support a caption, and header-based separators
The context menu for a saved address entry, with "Modify" and "General" header separators
Entries
Context registries contain a list of group objects keyed by name with support for a "weight". This gives some control order the ordering of menu items in case a plugin wants to access known groups and insert their commands into a suitable location. A better API is probably needed.
Entries are the actual menu item models, which are represented as the IContextObject
interface.
IContextEntry
is for actual menu items, but things like separators and captions just use IContextObject
Currently, there's only 2 types of groups:
- Static groups, which contain a list of entry instances.
- Dynamic groups, which contains a generator callback which can create entries based on the available context, and they're injected into the context menu at the location of the dynamic group entry (which is a placeholder entry so that the generator system knows where to put the items).
There's also the ContextCapturingMenu
, which is used as a window's top level menu. This menu captures the fully-inherited IContextData of the control that was focused just before a menu item was opened in said menu