Search code examples
objective-cmacoscocoacocoa-sheet

How to show an NSWindow as sheet at specific location


I have a window like this, having 3 subviews, each one of them has button. On click of those- I need to show sheet.

enter image description here

enter image description here

By using this code, sheet comes in centre of the window.

- (IBAction)closeSubWindow:(id)sender{
    [NSApp endSheet:self.subWindow];
    [self.subWindow orderOut:nil];
    
}

- (IBAction)showSubWindow:(id)sender {
    [NSApp beginSheet:self.subWindow
       modalForWindow:self.window
        modalDelegate:self
       didEndSelector:nil
          contextInfo:nil];
}

Is there any option or way to show the sheet at specific co-ordinates?

EDIT:

My current implementation is by using NSPopover. Can I make this NSPopover to animate like sheet?


Solution

  • Take a look at the NSWindow delegate method -window:willPositionSheet:usingRect: