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

Like this? Share it with your network

Share

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

on

  • 236 views

Cocoa勉強会#23

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

Statistics

Views

Total Views
236
Views on SlideShare
236
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Cocoa勉強会#23-カスタムシートとModality Document 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