• 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
Odd sheet behavior
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Odd sheet behavior


  • Subject: Odd sheet behavior
  • From: David Newberry <email@hidden>
  • Date: Sun, 25 Aug 2002 19:21:43 -0700

Hello all,

I'm working on putting up a custom sheet. This is the code they offer in the docs (modified for my app):

[NSApp beginSheet:Panel
modalForWindow:Window2
modalDelegate:nil
didEndSelector:nil
contextInfo:nil];
[NSApp runModalForWindow: Panel];
// Sheet is up here.
[NSApp endSheet:Panel];
[Panel orderOut:self];

They also note that this code needs to be put in the action for the sheet'
s close button:

[NSApp stopModal];

All this works well, but my sheet has two buttons (OK and Cancel). I could set a global var, but yuck! If I put up a new window in the OK button's action, it gets shown before the sheet is hidden. Instead, I thought I'd take this approach: I'd remove the two lines that get called after stopModal is called and put them in my button actions. So now I have this:

[NSApp beginSheet:Panel
modalForWindow:Window2
modalDelegate:nil
didEndSelector:nil
contextInfo:nil];
[NSApp runModalForWindow: Panel];

And in my Cancel action:

[NSApp stopModal];
[NSApp endSheet:Panel];
[Panel orderOut:self];

And in my OK action:

[NSApp stopModal];
[NSApp endSheet:Panel];
[Panel orderOut:self];

[self actionThatPutsUpANewWindow];

This appears to function properly the first time, but... doesn't. I can't really describe the behavior that I get but it is most certainly not right.

So it seems that for some reason endSheet: (and possibly also oderOut:) have to be called from the method that puts up the sheet. That seems pretty improbable... am I missing something obvious?

Thanks,
-David Newberry
_______________________________________________
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.

  • Follow-Ups:
    • Re: Odd sheet behavior
      • From: Ryan Stevens <email@hidden>
  • Prev by Date: Re: keyEventWithType
  • Next by Date: Re: keyEventWithType
  • Previous by thread: Re: keyEventWithType
  • Next by thread: Re: Odd sheet behavior
  • Index(es):
    • Date
    • Thread