NSDrawer Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.0 and later. |
| Companion guide | |
| Declared in | NSDrawer.h |
Overview
An NSDrawer object is a user interface element that contains and displays view objects including NSTextView, NSScrollView, NSBrowser, and other classes that inherit from NSView. A drawer is associated with a window, called its parent, and can appear only while its parent is visible onscreen. A drawer cannot be moved or ordered independently of a window, but is instead attached to one edge of its parent and moves along with it.
Tasks
Creating Drawers
Opening and Closing Drawers
Managing Drawer Size
-
– contentSize -
– leadingOffset -
– maxContentSize -
– minContentSize -
– setContentSize: -
– setLeadingOffset: -
– setMaxContentSize: -
– setMinContentSize: -
– setTrailingOffset: -
– trailingOffset
Managing Drawer Edges
Managing Drawer Views
Instance Methods
close
If the receiver is open, this method closes it.
Discussion
Calling close on a closed drawer does nothing. You can get the state of a drawer by sending it state.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDrawer.hclose:
An action method to close the receiver.
Parameters
- sender
A user interface element, such as a button or menu item, that invokes the action method.
Discussion
This method is an action method and likely would not be invoked programatically. Rather, it is an action that is commonly connected in Interface Builder.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDrawer.hcontentSize
Returns the size of the receiver’s content area.
Return Value
The size of the receiver’s content area.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDrawer.hcontentView
Returns the receiver’s content view.
Return Value
The receiver’s content view.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDrawer.hdelegate
Returns the receiver’s delegate.
Return Value
The receiver’s delegate.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDrawer.hedge
Returns the edge of the window that the receiver is connected to.
Return Value
The edge of the parent window at which the drawer is attached. See “Constants” for a list of edge constants and locations.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDrawer.hinitWithContentSize:preferredEdge:
Creates a new drawer with the given size on the specified edge of the parent window.
Parameters
- contentSize
The size of the new drawer.
- edge
The edge to which to attach the new drawer.
Discussion
You must specify the parent window and content view of the drawer using the methods in this class. When you create a drawer in Interface Builder, this constructor is invoked. The NSDrawer Inspector in Interface Builder allows you to set the edge, and you can specify the size by changing the content view in Interface Builder.
See Positioning and Sizing a Drawer for additional detail on content size and drawer positioning.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDrawer.hleadingOffset
Returns the receiver’s leading offset.
Return Value
The receiver’s leading offset. This is the distance from the top or left edge of the parent window to the drawer.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDrawer.hmaxContentSize
Returns the maximum allowed size of the receiver’s content area.
Return Value
The maximum size of the receiver’s content area. This is useful for determining if an opened drawer would fit onscreen given the current window position.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDrawer.hminContentSize
Returns the minimum allowed size of the receiver’s content area.
Return Value
The minimum size of the receiver’s content area.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDrawer.hopen
If the receiver is closed, this method opens it.
Discussion
Calling open on an open drawer does nothing. You can get the state of a drawer by sending it state. If an edge is not specified, an attempt will be made to choose an edge based on the space available to display the drawer onscreen. If you need to ensure that a drawer opens on a particular edge, use openOnEdge:.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDrawer.hopen:
An action method to open the drawer.
Parameters
- sender
A user interface element, such as a button or menu item, that invokes the action method.
Discussion
This method is an action method and likely would not be invoked programatically. Rather, it is an action that is commonly connected in Interface Builder.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDrawer.hopenOnEdge:
Causes the receiver to open on the specified edge of the parent window.
Parameters
- edge
The edge of the parent window on which to open the receiver. See “Constants” for a list of edge constants and locations.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDrawer.hparentWindow
Returns the receiver’s parent window.
Return Value
The receiver’s parent window. By definition, a drawer can appear onscreen only if it has a parent.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDrawer.hpreferredEdge
Returns the receiver’s preferred, or default, edge.
Return Value
The receiver’s preferred edge. If a drawer is told to open and an edge is not specified at that time, it opens on its preferred edge. When you a create a drawer with Interface Builder, the preferred edge is set to the left by default.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDrawer.hsetContentSize:
Sets the size of the receiver’s content area.
Parameters
- size
The new size of the receiver’s content area. See Positioning and Sizing a Drawer for additional detail.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDrawer.hsetContentView:
Sets the receiver’s content view.
Parameters
- aView
The content view of the receiver. Rather than connect a drawer to its content view in Interface Builder, you can specify it programatically with this method.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDrawer.hsetDelegate:
Sets the receiver’s delegate.
Parameters
- anObject
The object to assign as the receiver’s delegate. The object must conform to the NSDrawerDelegate Protocol Reference.
Discussion
You may find it useful to associate a delegate with a drawer, especially since drawers do not open and close instantly. A drawer’s delegate can better regulate drawer behavior.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDrawer.hsetLeadingOffset:
Sets the receiver’s leading offset.
Parameters
- offset
The leading offset of the receiver. This is the distance from the top or left edge of the parent window to the drawer. See Positioning and Sizing a Drawer for additional detail.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDrawer.hsetMaxContentSize:
Specifies the maximum size of the receiver’s content area.
Parameters
- size
The new maximum size of the receiver’s content area. See Positioning and Sizing a Drawer for additional detail.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDrawer.hsetMinContentSize:
Specifies the minimum size of the receiver’s content area.
Parameters
- size
The new minimum size of the receiver’s content area. See Positioning and Sizing a Drawer for additional detail.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDrawer.hsetParentWindow:
Sets the receiver’s parent window.
Parameters
- parent
The parent window of the receiver. Every drawer must be associated with a parent window for a drawer to appear onscreen. If this argument is
nil, the drawer is removed from its parent.
Discussion
Changes in a drawer’s parent window do not take place while the drawer is onscreen; they are delayed until the drawer next closes.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDrawer.hsetPreferredEdge:
Sets the receiver’s preferred, or default, edge.
Parameters
- preferredEdge
The edge on which the receiver should open by default. A drawer can be told to open on a specific
edge; if an edge is not specified, however, it opens on the preferred edge.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDrawer.hsetTrailingOffset:
Sets the receiver’s trailing offset.
Parameters
- offset
The receiver’s trailing offset. This is the distance to the right or bottom edge of the drawer from the right or bottom edge of the parent window. See Positioning and Sizing a Drawer for additional detail.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDrawer.hstate
Returns the state of the receiver.
Return Value
The drawer's state. Refer to NSDrawerState for a list of possible values.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDrawer.htoggle:
Toggles the drawer open or closed.
Parameters
- sender
The sender of the message.
Discussion
If the receiver is closed, or in the process of either opening or closing, it is opened. Otherwise, the drawer is closed.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDrawer.htrailingOffset
Returns the receiver’s trailing offset.
Return Value
The receiver’s trailing offset. This is the distance to the right or bottom edge of the drawer from the right or bottom edge of the parent window.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSDrawer.hConstants
NSDrawerState
These constants specify the possible states of a drawer.
typedef enum _NSDrawerState {
NSDrawerClosedState = 0,
NSDrawerOpeningState = 1,
NSDrawerOpenState = 2,
NSDrawerClosingState = 3
} NSDrawerState;
Constants
NSDrawerClosedStateThe drawer is closed (not visible onscreen).
Available in OS X v10.0 and later.
Declared in
NSDrawer.h.NSDrawerOpeningStateThe drawer is in the process of opening.
Available in OS X v10.0 and later.
Declared in
NSDrawer.h.NSDrawerOpenStateThe drawer is open (visible onscreen).
Available in OS X v10.0 and later.
Declared in
NSDrawer.h.NSDrawerClosingStateThe drawer is in the process of closing.
Available in OS X v10.0 and later.
Declared in
NSDrawer.h.
Discussion
These constants are returned by state.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDrawer.hNotifications
NSDrawerDidCloseNotification
The notification object is the NSDrawer object that closed. This notification does not contain a userInfo dictionary.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDrawer.hNSDrawerDidOpenNotification
The notification object is the NSDrawer object that opened. This notification does not contain a userInfo dictionary.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDrawer.hNSDrawerWillCloseNotification
The notification object is the NSDrawerobject about to close. This notification does not contain a userInfo dictionary.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDrawer.hNSDrawerWillOpenNotification
The notification object is the NSDrawer object about to open. This notification does not contain a userInfo dictionary.
Availability
- Available in OS X v10.0 and later.
Declared In
NSDrawer.h© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-03-31)