Nested sheets
Nested sheets
- Subject: Nested sheets
- From: Bill Cheeseman <email@hidden>
- Date: Wed, 30 Mar 2005 05:47:24 -0500
The HIG is adamant that one must never allow nested sheets on a window. Do
people generally agree with this, as a matter of design?
I question this rule. One of the design goals for sheets in the first place,
according to the HIG, is to avoid the experience of an alert that pops up
somewhere else on the screen, separated from the window to which it applies.
Yet the HIG tells us we must force the user to experience this very abrupt
disconnect if the window already has a sheet open.
I believe it is less jarring for a small, secondary sheet to be presented on
top of a larger primary sheet, at least in the limited case where it is
occasionally (but not always) necessary to ask the user a simple question
about how to carry out the command chosen on the primary sheet.
An example: My app is a single-window, non-document-based utility, so most
dialogs are appropriately implemented as sheets on the single window. The
primary sheet is a standard open file sheet used to select a file for
import. The user chooses a file to import and clicks the primary sheet's
default button. Sometimes (but not always), the chosen file contains an item
that conflicts with an item already imported into the utility, and I need to
present a small secondary dialog or sheet to ask the user whether to replace
the existing item. If the user chooses not to replace the existing item, the
secondary dialog or sheet is dismissed and the import is canceled, but the
primary sheet remains open so the user can choose another file to import (or
cancel the primary sheet). If the user chooses to prefer the new item, the
import is carried out and both the secondary sheet or dialog and the primary
sheet are dismissed.
In a situation like this, I believe the secondary dialog should be a nested
sheet, to keep it tightly associated with the primary sheet to which it
relates.
The Cocoa documentation on sheets says that Cocoa is not designed to support
nested sheets. This is a poor reason to adopt the HIG's absolute rule
prohibiting nested sheets -- especially since it isn't true. It's very easy
to implement nested sheets in Cocoa, even on NSOpenPanel sheets. I insert my
code to present and handle the secondary sheet in the action method for the
primary sheet's default button, and the secondary sheet's didEndSelector
sets things up as the user desires before the primary sheet's default button
action method carries out its primary action. To do this with an
NSOpenPanel, I subclass NSOpenPanel, override its -ok: method to invoke a
custom delegate method before sending -[super ok:], and implement the custom
delegate method in my main window controller (the delegate). The custom
delegate method presents and handles the secondary sheet before super's -ok:
action method carries out its action.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
PreFab Software - http://www.prefab.com/scripting.html
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden