• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Can a sheet appear at an arbitrary window position?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can a sheet appear at an arbitrary window position?


  • Subject: Re: Can a sheet appear at an arbitrary window position?
  • From: Ryan Stevens <email@hidden>
  • Date: Sat, 8 May 2004 06:51:47 -0700

Here's how I do it..

@implementation HiddenWindow

- (id)initWithContentRect:(NSRect)frame
{
self = [super initWithContentRect:frame
styleMask:NSBorderlessWindowMask backing:NSBackingStoreNonretained
defer:YES];
[self setLevel:NSNormalWindowLevel];
[self setIgnoresMouseEvents:YES];
[self setAlphaValue:0.0];

return self;
}

// don't allow our sheets to move this window
- (void)setFrameOrigin:(NSPoint)aPoint { return; }
@end


Then you'd use it like..

HiddenWindow *hiddenWindow = [[HiddenWindow alloc]
initWithContentRect:frame];

// keep hiddenWindow (and sheet) fixed to yourWindow during resize and
drag operations
[yourWindow addChildWindow:hiddenWindow ordered:NSWindowAbove];
[hiddenWindow orderFront:nil];
[NSApp beginSheet:yourSheet modalForWindow:hiddenWindow ....];


Another thing you might want to think about is if it's ok for the user
to quit the app while the sheet is open. To allow for that, I
subclassed NSApplication...

- (void)terminate:(id)sender
{
if (![self delegate]) // there's nobody to say we can't quit
[[NSNotificationCenter defaultCenter]
postNotificationName:@"CloseAllSheetsNowThankYou" object:self];
else // there's a delegate so ask permission..
if ([[self delegate]
respondsToSelector:@selector(applicationShouldTerminate:)])
if ([[self delegate] applicationShouldTerminate:self])
[[NSNotificationCenter defaultCenter]
postNotificationName:@"CloseAllSheetsNowThankYou" object:self];

[super terminate:sender];
}


On May 8, 2004, at 1:46 AM, Greg Hulands wrote:

> You could make a transparent window over the top of the box and run
> the sheet out of that window. I don't know if the window is
> transparent, then the sheet will be as well, you will have to see.
>
> HTH,
> Greg
>
> On 08/05/2004, at 3:32 PM, Lance Drake wrote:
>
>> Hi Cocoa-Dev Folks,
>>
>> Perhaps it's not a suggested approach, but is it possible to cause a
>> sheet to appear from some place other than the title bar of a window?
>> For instance, I have several NSBoxes which surround several
>> NSTableViews. For purposes of clarity about which NSTableView the
>> sheet might pertain, if I wanted to cause a sheet to appear from the
>> upper lip of one of those NSBoxes, can anyone suggest how that might
>> be accomplished.
>>
>> Thanks,
>>
>> Lance Drake
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Can a sheet appear at an arbitrary window position? (From: Lance Drake <email@hidden>)

  • Prev by Date: Re: Java vs Objetive-C
  • Next by Date: Re: Archiving ABPerson
  • Previous by thread: Re: Can a sheet appear at an arbitrary window position?
  • Next by thread: Re[3]: Can a sheet appear at an arbitrary window position?
  • Index(es):
    • Date
    • Thread