• 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: beginSheet:modalForWindow:modalDelegate:didEndSelector:contextI nfo:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: beginSheet:modalForWindow:modalDelegate:didEndSelector:contextI nfo:


  • Subject: Re: beginSheet:modalForWindow:modalDelegate:didEndSelector:contextI nfo:
  • From: kristin <email@hidden>
  • Date: Thu, 24 May 2001 10:11:09 -0700

Jason,
Your approach of connecting the button to an action method that calls [NSApp endSheet:myWindowSheet] is correct. (If you had multiple buttons, you might want to instead connect them to a method that would call [NSApp endSheet:returnCode:], passing a returnCode to indicate which button was pressed).

When you call endSheet:, the document modal session will end, but the sheet itself will not be dismissed. Your didEndSelector will be called at this point. The idea is that you may want to manage the sheet dismissal yourself, since you may want to order out both the document and attached sheet at the same time (without the sheet effect). So, you must order out the sheet in your didEndSelector.

-(void)didEndSheet:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo {
[sheet orderOut:nil];
// do whatever else you need to do, which may be nothing...
}

Kristin


On Thursday, May 24, 2001, at 08:47 AM, email@hidden wrote:

Mr. Peyton,

thank you for your help with NSBeginSheet. i ended up figuring it out shortly before you emailed me the answer by looking at TextEdit.app's source code. Go figure. However, here's one where i have not found any example code..

i am trying to run a window as a sheet (for the eventual purpose of using it for some data entry, a task beyond that of simply having the user click one of maybe three buttons) and have successfully been able to run the sheet. however, i can not seem to make it go away. i have designed a window in IB which currently has only a bit of text and a button. i can connect the button to an action method in my window controller and have it do anything i want. my question is, how do i make didEndSelector work? where does it come from? obviously i need a button which tells the sheet to end, but i'm lost as to how. how do i tell the sheet when to end? is there a connection i need to make in IB?

i have tried connecting my sole button to a action method and having this message in the method

[NSApp endSheet:myWindowSheet];

but nothing happens.

my use of the beginSheet method is this:

[NSApp beginSheet:[self myWindowSheet]
modalForWindow:[self window]
modalDelegate:self
didEndSelector:@selector(theEnd:)
contextInfo:NULL];

i've also tried declaring a method named endSheet: and placing that in the didEndSelector, but to no avail.

thank you for any help you can provide.

Jason Moore
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev


References: 
 >beginSheet:modalForWindow:modalDelegate:didEndSelector:contextI nfo: (From: email@hidden)

  • Prev by Date: Re: Icon in window title
  • Next by Date: Pasting code (Was: Re: Obj-C with C problems)
  • Previous by thread: beginSheet:modalForWindow:modalDelegate:didEndSelector:contextI nfo:
  • Next by thread: Re: beginner's question (Cocoa + QT)
  • Index(es):
    • Date
    • Thread