Cocoa勉強会#23-カスタムシートとModality

446 views

Published on

Cocoa勉強会#23
2007/5/12
カスタムシートとModality
新居雅行

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
446
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Cocoa勉強会#23-カスタムシートとModality

  1. 1. 2014/2/23 Cocoa #23 file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy23-CustomSheet/CocoaStudy-CustSheet.html 1/12
  2. 2. 2014/2/23 Cocoa #23 file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy23-CustomSheet/CocoaStudy-CustSheet.html 2/12
  3. 3. 2014/2/23 Cocoa #23 file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy23-CustomSheet/CocoaStudy-CustSheet.html 3/12
  4. 4. 2014/2/23 Cocoa #23 file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy23-CustomSheet/CocoaStudy-CustSheet.html 4/12
  5. 5. 2014/2/23 Cocoa #23 #import <Cocoa/Cocoa.h> @interface MyDocument : NSDocument { IBOutlet NSWindow *mySheet; } - (IBAction)openMySheet:(id)sender; - (IBAction)closeMySheet:(id)sender; - (IBAction)terminate:(id)dummy; @end file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy23-CustomSheet/CocoaStudy-CustSheet.html 5/12
  6. 6. 2014/2/23 Cocoa #23 #import "MyDocument.h" @implementation MyDocument - (IBAction)openMySheet:(id)sender { } - (IBAction)closeMySheet:(id)sender { } - (id)init { self = [super init]; if (self) { } return self; } - (NSString *)windowNibName { return @"MyDocument"; } - (void)windowControllerDidLoadNib:(NSWindowController *) aController { [super windowControllerDidLoadNib:aController]; } - (NSData *)dataRepresentationOfType:(NSString *)aType { return nil; } - (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType { return YES; } @end file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy23-CustomSheet/CocoaStudy-CustSheet.html 6/12
  7. 7. 2014/2/23 Cocoa #23 file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy23-CustomSheet/CocoaStudy-CustSheet.html 7/12
  8. 8. 2014/2/23 Cocoa #23 - (IBAction)openMySheet:(id)sender { NSLog(@"Cought the message 'openMySheet'."); NSApplication* myApp = [NSApplication sharedApplication]; [myApp beginSheet: mySheet modalForWindow: [[[self windowControllers]lastObject]window] modalDelegate: self didEndSelector: @selector(mySheetDidEnd:returnCode:contextInfo:) contextInfo: nil]; } - (void) mySheetDidEnd: (NSWindow *) sheet returnCode: (int) returnCode contextInfo: (void *) contextInfo{ NSLog(@"Cought the message 'mySheetDidEnd'."); [mySheet orderOut:self]; } - (IBAction)closeMySheet:(id)sender { NSLog(@"Cought the message 'closeMySheet'."); NSApplication* myApp = [NSApplication sharedApplication]; [myApp endSheet: mySheet]; } file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy23-CustomSheet/CocoaStudy-CustSheet.html 8/12
  9. 9. 2014/2/23 Cocoa #23 file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy23-CustomSheet/CocoaStudy-CustSheet.html 9/12
  10. 10. 2014/2/23 Cocoa #23 - (IBAction)terminate:(id)dummy { NSLog(@"Cought the message 'terminate'."); NSApplication* myApp = [NSApplication sharedApplication]; [[myApp orderedDocuments] makeObjectsPerformSelector:@selector(closeMySheet:) withObject:nil]; [myApp terminate:dummy]; } file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy23-CustomSheet/CocoaStudy-CustSheet.html 10/12
  11. 11. 2014/2/23 Cocoa #23 - (IBAction)openMySheet:(id)sender { NSLog(@"Cought the message 'openMySheet'."); NSApplication* myApp = [NSApplication sharedApplication]; [myApp beginSheet: mySheet modalForWindow: [[[self windowControllers]lastObject]window] modalDelegate: self didEndSelector: @selector(mySheetDidEnd:returnCode:contextInfo:) contextInfo: nil]; file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy23-CustomSheet/CocoaStudy-CustSheet.html 11/12
  12. 12. 2014/2/23 Cocoa #23 [myApp endSheet: mySheet]; [myApp runModalForWindow:mySheet]; } - (void) mySheetDidEnd: (NSWindow *) sheet returnCode: (int) returnCode contextInfo: (void *) contextInfo{ NSLog(@"Cought the message 'mySheetDidEnd'."); } - (IBAction)closeMySheet:(id)sender { NSLog(@"Cought the message 'closeMySheet'."); NSApplication* myApp = [NSApplication sharedApplication]; [myApp stopModal]; [mySheet orderOut:self]; } file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy23-CustomSheet/CocoaStudy-CustSheet.html 12/12

×