Starting an alert sheet from an NSWindowController that owns a user-editable sheet

  • Hi All,

    I'm writing a document-based application that works similarly to
    Keynote/Pages/Numbers on loading.  When the user want to create a new
    document, the document window opens and a sheet drops down with some
    options, one is to specify a directory.  What I want to do is to
    present a document-modal error if possible, but the HIG say that you
    shouldn't (and Cocoa can't) stack a sheet on a sheet.

    So I need to order out the initial sheet and present the error alert
    (e.g. that directory wasn't write-able) as another sheet, then bring
    my original sheet back.

    The problem is, I've factored out all the code that managed and
    instantiates the sheet into a NSWindowController subclass, as per the
    advice on Wil Shipley's blog.

    Any ideas how I can do this from within the NSWindowController
    subclass, as this seems like it would be the appropriate place to
    handle all my errors as all the ivars (like the one that holds the
    directory name that the user is trying to create) are within the
    controller class already because they are used by the sheet.

    Its easy enough to just disable the button that ends the sheet, but I
    want to tell the user that they did wrong on the document they are
    working on without running an application-modal alert when it really
    is a document-modal error.

    Thanks for any advice,

    Jonathan
  • on 1/17/08 10:56 AM, <j.p.dann...> purportedly said:

    > Any ideas how I can do this from within the NSWindowController
    > subclass, as this seems like it would be the appropriate place to
    > handle all my errors as all the ivars (like the one that holds the
    > directory name that the user is trying to create) are within the
    > controller class already because they are used by the sheet.

    Have your NSWindowController be the delegate of the error alert sheet. In
    the delegate method, order out the error and start the original sheet again.

    Best,

    Keary Suska
    Esoteritech, Inc.
    "Demystifying technology for your home or business"
  • On Jan 17, 2008, at 9:56 AM, Jonathan Dann wrote:

    > ...but the HIG say that you shouldn't (and Cocoa can't) stack a
    > sheet on a sheet.

    Unfortunately Cocoa can.....
    http://www.sethwillits.com/temp/LeopardSheetBug.mov

    (I'm not sure whyyyy it does it here, but it does.)

    > So I need to order out the initial sheet and present the error alert
    > (e.g. that directory wasn't write-able) as another sheet, then bring
    > my original sheet back.
    >
    > The problem is, I've factored out all the code that managed and
    > instantiates the sheet into a NSWindowController subclass, as per
    > the advice on Wil Shipley's blog.

    Why is that a problem?

    > Its easy enough to just disable the button that ends the sheet, but
    > I want to tell the user that they did wrong on the document they are
    > working on without running an application-modal alert when it really
    > is a document-modal error.

    If you have room, maybe you could stick an error message in the first
    sheet somewhere.

    --
    Seth Willits
  • Seth Willits wrote:
    > On Jan 17, 2008, at 9:56 AM, Jonathan Dann wrote:
    >
    >> ...but the HIG say that you shouldn't (and Cocoa can't) stack a sheet
    >> on a sheet.
    >
    > Unfortunately Cocoa can.....
    > http://www.sethwillits.com/temp/LeopardSheetBug.mov
    >
    > (I'm not sure whyyyy it does it here, but it does.)
    I haven't watched your movie, but I've actually got an open bug on
    NSSavePanel putting one sheet on top of another. It should not do that.
    I am pretty sure that NSSavePanel has not changed, but instead the sheet
    code in AppKit now allows two sheets at once. Previously, if you tried
    it, the second sheet would simply not attach to the window at all; this
    changed in Leopard and stacked sheets now function if you ask for them.
    My suspicion is that the code always tried to stack sheets, but in 10.4
    and before, the OS automatically converted the second sheet into a
    regular dialog.
    I honestly expect that they will update the HIG to allow stacked sheets.
    (Though personally I think it is ugly and confusing.) At first they
    rejected my bug as "behaves as expected" and only reopened it when I
    pointed out the page and line of the HIG that says not to do it.
  • On Jan 18, 2008 7:15 PM, John Stiles <JStiles...> wrote:

    > I honestly expect that they will update the HIG to allow stacked sheets.
    > (Though personally I think it is ugly and confusing.)

    I rather like it! But then I'm wierd, I think app-modal dialogs should
    be sheets attached to the menubar :)

    Maybe dimming the sheet underneath and/or increasing the drop shadow
    would make it less ugly and confusing...

    Hamish
  • On Jan 18, 2008, at 11:15 AM, John Stiles wrote:

    > I haven't watched your movie, but I've actually got an open bug on
    > NSSavePanel putting one sheet on top of another. It should not do
    > that.

    That's exactly what the 5 second long movie is. Eric said it was a
    bug.  I filed it as well.

    It wouldn't be so bad if the second sheet actually displayed _in
    front_ of the first sheet rather than behind it.

    --
    Seth Willits
  • Heh, I didn't see that (didn't watch the movie because visiting links is
    a hassle from my work computer, firewalls aplenty). Typically the second
    sheet is layered properly :)

    Seth Willits wrote:
    > On Jan 18, 2008, at 11:15 AM, John Stiles wrote:
    >
    >> I haven't watched your movie, but I've actually got an open bug on
    >> NSSavePanel putting one sheet on top of another. It should not do that.
    >
    > That's exactly what the 5 second long movie is. Eric said it was a
    > bug.  I filed it as well.
    >
    > It wouldn't be so bad if the second sheet actually displayed _in
    > front_ of the first sheet rather than behind it.
    >
    >
    > --
    > Seth Willits
previous month january 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today