ContextMenu.IHandler

References
public interface ContextMenu.IHandler : Widget.IHandler, Menu.ISubmenuHandler
Handler interface for the ContextMenu

Properties

ID

string ID { get; set; }
Gets or sets an ID for the widget
inherited fromWidget.IHandler
Remarks: Some platforms may use this to identify controls (e.g. web)

IncludeSystemItems

#Since v2.12
ContextMenuSystemItems IncludeSystemItems { get; set; }
Gets or sets which system items will be automatically included with the menu.
Remarks: This must be applied to the native menu immediately so that it also takes effect for menus assigned to a control via Control.ContextMenu, which are shown by the operating system without going through Show(Control, PointF?).
The system items to include with the menu. Defaults to ContextMenuSystemItems.All

NativeHandle

nint NativeHandle { get; }
Gets the native platform-specific handle for integration purposes
inherited fromWidget.IHandler

Methods

AddMenu

void AddMenu(int index, MenuItem item)
Adds the menu item
inherited fromMenu.ISubmenuHandler

HandleEvent

void HandleEvent(string id, bool defaultEvent = false)
Called to handle a specific event
inherited fromWidget.IHandler
Remarks: Most events are late bound by this method. Instead of wiring all events, this will be called with an event string that is defined by the control. This is called automatically when attaching to events, but must be called manually when users of the control only override the event's On... method.
id (string)ID of the event to handle
defaultEvent (bool = false)True if the event is default (e.g. overridden or via an event handler subscription)

Initialize

void Initialize()
Called after the widget is constructed
inherited fromWidget.IHandler
Remarks: This gets called automatically after the control is constructed and the Widget.IHandler.Widget and Widget.Platform properties are set. When the handler has specialized construction methods, then the AutoInitializeAttribute can be used to disable automatic initialization. In this case, it is the responsibility of the subclass to call Widget.Initialize()

Show

#
void Show(Control relativeTo, PointF? location)
Show the context menu relative to the specified control
relativeTo (Control)Control to show the menu relative to, or null to use screen co-ordinates for location
location (PointF?)Location to place the upper left of the context menu, or null to use the mouse position

UnhandleEvent

virtual void UnhandleEvent(string id)
Called when the last subscriber to an event has been removed, so the platform can stop listening for it.
inherited fromWidget.IHandler
Remarks: Only reached for events whose remove accessor uses PropertyStore.RemoveHandlerEvent(string, Delegate), and only for events that were attached because something subscribed to them. An event attached because the widget overrides its On[Event] method is never detached, since it has to keep firing regardless. Most events stay attached for the life of the widget, which costs nothing. Detaching is worth wiring up for the few that hold onto something expensive or process wide while they are attached, such as a system wide hook. Handlers deriving from WidgetHandler<TWidget> get an implementation of this that dispatches to WidgetHandler<TWidget>.DetachEvent(string), which is what to override.
id (string)ID of the event to stop handling