LoginSignup
0
0

More than 5 years have passed since last update.

windowWillBeginSheetのメッセージの飛び先

Posted at

シートを表示して初期化などの処理を行いたいとき、windowWillBeginSheetのイベント内で行う事になると思われるが、このメッセージは作成したシートではなく、シートの発行元である親Windowに飛ばされる。

よって、親WindowにwindowWillBeginSheetを実装してシートの初期化処理を呼ぶというスタイルにしなければならない。

以下は親WindowのwindowWillBeginSheet実装例

sample_parent.h
    IBOutlet NSPanel *pnlTest;
    IBOutlet NSWindowController *winTest;
sample_parent.m
-(IBAction)onClicked_btnTest:(id)sender {

    [[NSApplication sharedApplication] beginSheet:pnlTest
                                   modalForWindow:self.window
                                    modalDelegate:self
                                   didEndSelector:@selector(onSheetDidEnd:
                                                            returnCode:
                                                            contextInfo:)
                                      contextInfo:nil];
}

// begin sheet
-(void)windowWillBeginSheet:(NSNotification *)notification {

    Viw_JobController *viwTest = (Viw_JobController *)winTest;
    [viwTest update];
}

// selector
-(void)onSheetDidEnd:(NSWindow *)winSheet
          returnCode:(int)intReturnCode
         contextInfo:(void *)datContextInfo {

    [pnlTest orderOut:nil];
}

以下は子Window(Sheet)

sample_child.m

-(void)update {

    // initialize code
}


0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0