| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in Mac OS X v10.0 and later. |
| Companion guide | |
| Declared in | NSDrawer.h |
| Related sample code |
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.
– contentSize
– leadingOffset
– maxContentSize
– minContentSize
– setContentSize:
– setLeadingOffset:
– setMaxContentSize:
– setMinContentSize:
– setTrailingOffset:
– trailingOffset
If the receiver is open, this method closes it.
- (void)close
Calling close on a closed drawer does nothing. You can get the state of a drawer by sending it state.
NSDrawer.hAn action method to close the receiver.
- (void)close:(id)sender
A user interface element, such as a button or menu item, that invokes the action method.
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.
NSDrawer.hReturns the size of the receiver’s content area.
- (NSSize)contentSize
The size of the receiver’s content area.
NSDrawer.hReturns the receiver’s content view.
- (NSView *)contentView
The receiver’s content view.
NSDrawer.hReturns the receiver’s delegate.
- (id < NSDrawerDelegate >)delegate
The receiver’s delegate.
NSDrawer.hReturns the edge of the window that the receiver is connected to.
- (NSRectEdge)edge
The edge of the parent window at which the drawer is attached. See “Constants” for a list of edge constants and locations.
NSDrawer.hCreates a new drawer with the given size on the specified edge of the parent window.
- (id)initWithContentSize:(NSSize)contentSize preferredEdge:(NSRectEdge)edge
The size of the new drawer.
The edge to which to attach the new drawer.
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.
NSDrawer.hReturns the receiver’s leading offset.
- (CGFloat)leadingOffset
The receiver’s leading offset. This is the distance from the top or left edge of the parent window to the drawer.
NSDrawer.hReturns the maximum allowed size of the receiver’s content area.
- (NSSize)maxContentSize
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.
NSDrawer.hReturns the minimum allowed size of the receiver’s content area.
- (NSSize)minContentSize
The minimum size of the receiver’s content area.
NSDrawer.hIf the receiver is closed, this method opens it.
- (void)open
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:.
NSDrawer.hAn action method to open the drawer.
- (void)open:(id)sender
A user interface element, such as a button or menu item, that invokes the action method.
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.
NSDrawer.hCauses the receiver to open on the specified edge of the parent window.
- (void)openOnEdge:(NSRectEdge)edge
The edge of the parent window on which to open the receiver. See “Constants” for a list of edge constants and locations.
NSDrawer.hReturns the receiver’s parent window.
- (NSWindow *)parentWindow
The receiver’s parent window. By definition, a drawer can appear onscreen only if it has a parent.
NSDrawer.hReturns the receiver’s preferred, or default, edge.
- (NSRectEdge)preferredEdge
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.
NSDrawer.hSets the size of the receiver’s content area.
- (void)setContentSize:(NSSize)size
The new size of the receiver’s content area. See Positioning and Sizing a Drawer for additional detail.
NSDrawer.hSets the receiver’s content view.
- (void)setContentView:(NSView *)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.
NSDrawer.hSets the receiver’s delegate.
- (void)setDelegate:(id < NSDrawerDelegate >)anObject
The object to assign as the receiver’s delegate. The object must conform to the NSDrawerDelegate Protocol Reference.
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.
NSDrawer.hSets the receiver’s leading offset.
- (void)setLeadingOffset:(CGFloat)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.
NSDrawer.hSpecifies the maximum size of the receiver’s content area.
- (void)setMaxContentSize:(NSSize)size
The new maximum size of the receiver’s content area. See Positioning and Sizing a Drawer for additional detail.
NSDrawer.hSpecifies the minimum size of the receiver’s content area.
- (void)setMinContentSize:(NSSize)size
The new minimum size of the receiver’s content area. See Positioning and Sizing a Drawer for additional detail.
NSDrawer.hSets the receiver’s parent window.
- (void)setParentWindow:(NSWindow *)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.
Changes in a drawer’s parent window do not take place while the drawer is onscreen; they are delayed until the drawer next closes.
NSDrawer.hSets the receiver’s preferred, or default, edge.
- (void)setPreferredEdge:(NSRectEdge)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.
NSDrawer.hSets the receiver’s trailing offset.
- (void)setTrailingOffset:(CGFloat)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.
NSDrawer.hReturns the state of the receiver.
- (NSInteger)state
The drawer's state. Refer to NSDrawerState for a list of possible values.
NSDrawer.hToggles the drawer open or closed.
- (void)toggle:(id)sender
The sender of the message.
If the receiver is closed, or in the process of either opening or closing, it is opened. Otherwise, the drawer is closed.
NSDrawer.hReturns the receiver’s trailing offset.
- (CGFloat)trailingOffset
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.
NSDrawer.hThese constants specify the possible states of a drawer.
typedef enum _NSDrawerState { NSDrawerClosedState = 0, NSDrawerOpeningState = 1, NSDrawerOpenState = 2, NSDrawerClosingState = 3 } NSDrawerState;
NSDrawerClosedStateThe drawer is closed (not visible onscreen).
Available in Mac OS X v10.0 and later.
Declared in NSDrawer.h.
NSDrawerOpeningStateThe drawer is in the process of opening.
Available in Mac OS X v10.0 and later.
Declared in NSDrawer.h.
NSDrawerOpenStateThe drawer is open (visible onscreen).
Available in Mac OS X v10.0 and later.
Declared in NSDrawer.h.
NSDrawerClosingStateThe drawer is in the process of closing.
Available in Mac OS X v10.0 and later.
Declared in NSDrawer.h.
These constants are returned by state.
NSDrawer.h
Posted whenever the drawer is closed.
The notification object is the NSDrawer object that closed. This notification does not contain a userInfo dictionary.
NSDrawer.h
Posted whenever the drawer is opened.
The notification object is the NSDrawer object that opened. This notification does not contain a userInfo dictionary.
NSDrawer.h
Posted whenever the drawer is about to close.
The notification object is the NSDrawerobject about to close. This notification does not contain a userInfo dictionary.
NSDrawer.h
Posted whenever the drawer is about to open.
The notification object is the NSDrawer object about to open. This notification does not contain a userInfo dictionary.
NSDrawer.h
Last updated: 2009-03-31