Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. NSString *const ToyboxNotification = @"com.sadun.ToyboxNotification";
  2. NSString *const kIdentity = @"kIdentity";
  3. NSString *const kTrigger = @"kTrigger";
  4. NSString *const kString = @"kString";
  5. NSString *const kValue = @"kValue";
  6. NSString *const kRadio = @"kRadio";
  7. NSString *const kRadioRow = @"kRadioRow";
  8. NSString *const kRadioColumn = @"kRadioColumn";
  9.  
  10. @implementation AppDelegate
  11. - (IBAction)postRadio:(NSMatrix <NSUserInterfaceItemIdentification> *)sender
  12. {
  13. NSNotification *note = [NSNotification notificationWithName:ToyboxNotification object:kRadio userInfo:@{kIdentity:sender.identifier, kRadioRow:@(sender.selectedRow), kRadioColumn:@(sender.selectedColumn)}];
  14. [[NSDistributedNotificationCenter defaultCenter] postNotification:note];
  15. }
  16.  
  17. - (IBAction)postString:(NSTextField <NSUserInterfaceItemIdentification> *)sender
  18. {
  19. NSNotification *note = [NSNotification notificationWithName:ToyboxNotification object:kString userInfo:@{kIdentity:sender.identifier, kString:sender.stringValue}];
  20. [[NSDistributedNotificationCenter defaultCenter] postNotification:note];
  21. }
  22.  
  23. - (IBAction)postValue:(NSControl <NSUserInterfaceItemIdentification> *)sender
  24. {
  25. NSNumber *value = @(0);
  26. if ([sender respondsToSelector:@selector(floatValue)])
  27. {
  28. NSSlider *slider = (NSSlider *) sender;
  29. value = @(slider.floatValue);
  30. }
  31. else if ([sender respondsToSelector:@selector(state)])
  32. {
  33. NSButton *button = (NSButton *) sender;
  34. value = @([button state] == NSOnState);
  35. }
  36.  
  37. NSNotification *note = [NSNotification notificationWithName:ToyboxNotification object:kValue userInfo:@{kIdentity:sender.identifier, kValue:value}];
  38. [[NSDistributedNotificationCenter defaultCenter] postNotification:note];
  39. }
  40.  
  41. - (IBAction)trigger:(id <NSUserInterfaceItemIdentification>)sender
  42. {
  43. NSNotification *note = [NSNotification notificationWithName:ToyboxNotification object:kTrigger userInfo:@{kIdentity:sender.identifier}];
  44. [[NSDistributedNotificationCenter defaultCenter] postNotification:note];
  45. }
  46. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement