Commits

Anonymous committed ed171fd

Added a notification to BWSelectableToolbar that tells you when a toolbar icon has been clicked

Comments (0)

Files changed (2)

BWSelectableToolbar.h

 
 @class BWSelectableToolbarHelper;
 
+// Notification that gets sent when a toolbar item has been clicked. You can get the button that was clicked by getting the object
+// for the key @"BWClickedItem" in the supplied userInfo dictionary.
+extern NSString * const BWSelectableToolbarItemClickedNotification;
+
 @interface BWSelectableToolbar : NSToolbar 
 {
 	BWSelectableToolbarHelper *helper;

BWSelectableToolbar.m

 #import "BWSelectableToolbarHelper.h"
 #import "NSWindow+BWAdditions.h"
 
+NSString * const BWSelectableToolbarItemClickedNotification = @"BWSelectableToolbarItemClicked";
+
 static BWSelectableToolbar *documentToolbar;
 static NSToolbar *editableToolbar;
 
 
 	selectedIndex = [itemIdentifiers indexOfObject:identifier];
 
+	[[NSNotificationCenter defaultCenter] postNotificationName:BWSelectableToolbarItemClickedNotification object:self userInfo:[NSDictionary dictionaryWithObject:sender forKey:@"BWClickedItem"]];
+	
 	[self switchToItemAtIndex:selectedIndex animate:YES];
 }