Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSString *const ToyboxNotification = @"com.sadun.ToyboxNotification";
- NSString *const kIdentity = @"kIdentity";
- NSString *const kTrigger = @"kTrigger";
- NSString *const kString = @"kString";
- NSString *const kValue = @"kValue";
- NSString *const kRadio = @"kRadio";
- NSString *const kRadioRow = @"kRadioRow";
- NSString *const kRadioColumn = @"kRadioColumn";
- @implementation AppDelegate
- - (IBAction)postRadio:(NSMatrix <NSUserInterfaceItemIdentification> *)sender
- {
- NSNotification *note = [NSNotification notificationWithName:ToyboxNotification object:kRadio userInfo:@{kIdentity:sender.identifier, kRadioRow:@(sender.selectedRow), kRadioColumn:@(sender.selectedColumn)}];
- [[NSDistributedNotificationCenter defaultCenter] postNotification:note];
- }
- - (IBAction)postString:(NSTextField <NSUserInterfaceItemIdentification> *)sender
- {
- NSNotification *note = [NSNotification notificationWithName:ToyboxNotification object:kString userInfo:@{kIdentity:sender.identifier, kString:sender.stringValue}];
- [[NSDistributedNotificationCenter defaultCenter] postNotification:note];
- }
- - (IBAction)postValue:(NSControl <NSUserInterfaceItemIdentification> *)sender
- {
- NSNumber *value = @(0);
- if ([sender respondsToSelector:@selector(floatValue)])
- {
- NSSlider *slider = (NSSlider *) sender;
- value = @(slider.floatValue);
- }
- else if ([sender respondsToSelector:@selector(state)])
- {
- NSButton *button = (NSButton *) sender;
- value = @([button state] == NSOnState);
- }
- NSNotification *note = [NSNotification notificationWithName:ToyboxNotification object:kValue userInfo:@{kIdentity:sender.identifier, kValue:value}];
- [[NSDistributedNotificationCenter defaultCenter] postNotification:note];
- }
- - (IBAction)trigger:(id <NSUserInterfaceItemIdentification>)sender
- {
- NSNotification *note = [NSNotification notificationWithName:ToyboxNotification object:kTrigger userInfo:@{kIdentity:sender.identifier}];
- [[NSDistributedNotificationCenter defaultCenter] postNotification:note];
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement