MenuBar.IHandler

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

Properties

ApplicationMenu

#
ButtonMenuItem ApplicationMenu { get; }
Gets the menu that contains application-level items.
Remarks: This allows you to change the application menu's text (File for most platforms, Application menu for OS X)
The application menu.

HelpMenu

#
ButtonMenuItem HelpMenu { get; }
Gets the help menu for the application for showing help items
Remarks: This allows you to change the help menu's text ('Help' by default on all platforms). This is usually used for the MenuBar.AboutItem on most platforms, other than OS X.
The help menu.

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)

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

CreateLegacySystemMenu

#
void CreateLegacySystemMenu()
Obsolete version to create a system menu using legacy symantics.
Remarks: For OS X, this means it uses the Application.Name instead of "Application". The new symantics uses "Application" always (OS X automatically shows the app's local name regardless of the name of the menu item).

CreateSystemMenu

#
void CreateSystemMenu()
Creates the system menu when it is loaded onto a window for the first time.

GetSystemCommands

#
IEnumerable<Command> GetSystemCommands()
Gets the system commands for the menu bar.
Remarks: The system commands should be used by the CreateSystemMenu() implementation by ID. Note that the commands may or may not exist in the collection of MenuBar.SystemCommands, as the collection can be modified to remove or modify commands before the menu is created.
The system commands to use when creating the system menu.

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()

SetAboutItem

#
void SetAboutItem(MenuItem item)
Gets or sets the item to show an about dialog for the application
Remarks: This allows you to set an item to show an about dialog for the application. OS X will place this in the Application menu, other platforms place this at the bottom of the Help menu.
The about item on the menu.
item (MenuItem)

SetQuitItem

#
void SetQuitItem(MenuItem item)
Gets or sets the quit item for the application.
Remarks: This allows you to set the quit item for the application. Some platforms (OS X) may add a quit item to the menu even if one is not defined as it is standard practice to allow users to quit the application with a menu item. This will be in the File menu for most platforms, and the Application menu for OS X.
The quit item on the menu.
item (MenuItem)

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