2

I want to display a window as a sheet, which is perfectly running with the following code:

[NSApp beginSheet:mySheet
   modalForWindow:myWindow
    modalDelegate:nil 
   didEndSelector:NULL
      contextInfo:NULL];

However, there is ONE LITTLE PROBLEM:

  • I'm using an implementation of Chromium Tabs, and - for some reason probably related to the inner logic of Chromium Tabs - the sheet seems to appear somewhat LOWER than where I'd want it to be... (Perhaps that's what is considered as the window "border", but anyway...)

enter image description here

What's wrong? How could I fix that?

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223

1 Answers1

8

Just found it :

In the window's delegate, we implement window:willPositionSheet:usingRect: like this

- (NSRect)window:(NSWindow *)window willPositionSheet:(NSWindow *)sheet 
       usingRect:(NSRect)rect 
{
    rect.origin.y += 11;  // or as much as we need
    return rect;
}
Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223
  • 1
    I would also suggest submitting a bug report to the project owners. Otherwise, you might end up chasing magic numbers from one version of OS X (or Chromium Tabs) to the next as sizes and styles change. – Joshua Nozzi Apr 03 '12 at 13:04
  • 1
    @JoshuaNozzi Good point, though in fact the version of Chromium Tabs I'm currently using is so heavily tweaked (by me) that if there is anyone I should notify, that would be me. :-) – Dr.Kameleon Apr 03 '12 at 13:36
  • Ah. That makes it harder to make a case. :-) – Joshua Nozzi Apr 03 '12 at 16:14
  • Having wasted hours trying to get`willPositionSheet` to work, you should note that this method should be in the parent window's delegate, not the sheet window's delegate. – AlexT May 24 '17 at 12:12