Share via


NSMenu.Notifications.ObserveDidRemoveItem Method

Definition

Overloads

ObserveDidRemoveItem(EventHandler<NSMenuItemIndexEventArgs>)

Strongly typed notification for the DidRemoveItemNotification constant.

public static Foundation.NSObject ObserveDidRemoveItem(EventHandler<AppKit.NSMenuItemIndexEventArgs> handler);
static member ObserveDidRemoveItem : EventHandler<AppKit.NSMenuItemIndexEventArgs> -> Foundation.NSObject

Parameters

handler
EventHandler<NSMenuItemIndexEventArgs>

The handler that responds to the notification when it occurs.

Returns

Token object that can be used to stop receiving notifications by either disposing it or passing it to RemoveObservers(IEnumerable<NSObject>).

Remarks

This method can be used to subscribe to DidRemoveItemNotification notifications.

// Listen to all notifications posted for any object
var token = NSMenu.Notifications.ObserveDidRemoveItem ((notification) => {
  Console.WriteLine ("Observed DidRemoveItemNotification!");
};

// Stop listening for notifications
token.Dispose ();

Applies to

ObserveDidRemoveItem(NSObject, EventHandler<NSMenuItemIndexEventArgs>)

Strongly typed notification for the DidRemoveItemNotification constant.

public static Foundation.NSObject ObserveDidRemoveItem(Foundation.NSObject objectToObserve, EventHandler<AppKit.NSMenuItemIndexEventArgs> handler);
static member ObserveDidRemoveItem : Foundation.NSObject * EventHandler<AppKit.NSMenuItemIndexEventArgs> -> Foundation.NSObject

Parameters

objectToObserve
NSObject

The specific object to observe.

handler
EventHandler<NSMenuItemIndexEventArgs>

The handler that responds to the notification when it occurs.

Returns

Token object that can be used to stop receiving notifications by either disposing it or passing it to RemoveObservers(IEnumerable<NSObject>).

Remarks

This method can be used to subscribe to DidRemoveItemNotification notifications.

// Listen to all notifications posted for a single object
var token = NSMenu.Notifications.ObserveDidRemoveItem (objectToObserve, (notification) => {
  Console.WriteLine ($"Observed DidRemoveItemNotification for {nameof (objectToObserve)}!");
};

// Stop listening for notifications
token.Dispose ();

Applies to