Your SlideShare is downloading. ×
  • Like
Cocoa勉強会#23-カスタムシートとModality
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

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

  • 120 views
Published

Cocoa勉強会#23 …

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

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
120
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. 2014/2/23 Cocoa #23 file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy23-CustomSheet/CocoaStudy-CustSheet.html 1/12
  • 2. 2014/2/23 Cocoa #23 file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy23-CustomSheet/CocoaStudy-CustSheet.html 2/12
  • 3. 2014/2/23 Cocoa #23 file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy23-CustomSheet/CocoaStudy-CustSheet.html 3/12
  • 4. 2014/2/23 Cocoa #23 file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy23-CustomSheet/CocoaStudy-CustSheet.html 4/12
  • 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. 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. 2014/2/23 Cocoa #23 file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy23-CustomSheet/CocoaStudy-CustSheet.html 7/12
  • 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. 2014/2/23 Cocoa #23 file:///Users/msyk/Desktop/cocoastudy/Cocoa-Study/CocoaStudy23-CustomSheet/CocoaStudy-CustSheet.html 9/12
  • 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. 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. 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