Share via


NSToolbar.Notifications.ObserveNSToolbarWillAddItem Method

Definition

Overloads

ObserveNSToolbarWillAddItem(EventHandler<NSToolbarItemEventArgs>)

Strongly typed notification for the NSToolbarWillAddItemNotification constant.

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

Parameters

handler
EventHandler<NSToolbarItemEventArgs>

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 NSToolbarWillAddItemNotification notifications.

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

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

Applies to

ObserveNSToolbarWillAddItem(NSObject, EventHandler<NSToolbarItemEventArgs>)

Strongly typed notification for the NSToolbarWillAddItemNotification constant.

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

Parameters

objectToObserve
NSObject

The specific object to observe.

handler
EventHandler<NSToolbarItemEventArgs>

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 NSToolbarWillAddItemNotification notifications.

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

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

Applies to