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
– drawerDidOpen:
delegate method
– drawerShouldOpen:
delegate method
– drawerWillOpen:
delegate method
– drawerWillResizeContents:toSize:
delegate method
– drawerDidClose:
delegate method
– drawerShouldClose:
delegate method
– drawerWillClose:
delegate method
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.h
An 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 each drawer comes with in Interface Builder.
NSDrawer.h
Returns the size of the receiver’s content area.
- (NSSize)contentSize
The size of the receiver’s content area.
NSDrawer.h
Returns the receiver’s content view.
- (NSView *)contentView
The receiver’s content view.
NSDrawer.h
Returns the receiver’s delegate.
- (id)delegate
The receiver’s delegate.
NSDrawer.h
Returns 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.h
Creates 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.h
Returns 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.h
Returns 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.h
Returns the minimum allowed size of the receiver’s content area.
- (NSSize)minContentSize
The minimum size of the receiver’s content area.
NSDrawer.h
If 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.h
An 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 each drawer comes with in Interface Builder.
NSDrawer.h
Causes 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.h
Returns 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.h
Returns 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.h
Sets 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.h
Sets 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.h
Sets the receiver’s delegate.
- (void)setDelegate:(id)anObject
The object to assign as the receiver’s delegate.
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. However, a drawer can be used without a delegate.
NSDrawer.h
Sets 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.h
Specifies 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.h
Specifies 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.h
Sets 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.h
Sets 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.h
Sets 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.h
Returns the state of the receiver.
- (NSInteger)state
The drawer's state. Refer to NSDrawerState
for a list of possible values.
NSDrawer.h
Toggles 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.h
Returns 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.h
Notifies the delegate that the drawer has closed.
- (void)drawerDidClose:(NSNotification *)notification
An NSDrawerDidCloseNotification
notification sent by the default notification center immediately after the drawer has closed.
NSDrawer.h
Notifies the delegate that the drawer has opened.
- (void)drawerDidOpen:(NSNotification *)notification
An NSDrawerDidOpenNotification
notification, sent by the default notification center immediately after the drawer has opened.
NSDrawer.h
Requests permission for a drawer to close.
- (BOOL)drawerShouldClose:(NSDrawer *)sender
The drawer being closed.
YES
to allow the drawer to close; NO
to prevent it from closing.
This method is invoked on user-initiated attempts to close a drawer by dragging it or when the close:
method is called.
NSDrawer.h
Requests permission for a drawer to open.
- (BOOL)drawerShouldOpen:(NSDrawer *)sender
The drawer requesting permission to open.
YES
if the drawer should open; NO
to prevent the drawer from opening.
This method is invoked on user-initiated attempts to open a drawer by dragging it or when the open:
method is called.
NSDrawer.h
Notifies the delegate the the drawer will close.
- (void)drawerWillClose:(NSNotification *)notification
An NSDrawerWillCloseNotification
notification sent by the default notification center immediately before the drawer is closed.
NSDrawer.h
Notifies the delegate that the drawer will open.
- (void)drawerWillOpen:(NSNotification *)notification
An NSDrawerWillOpenNotification
notification, sent by the default notification center immediately before the drawer is opened.
NSDrawer.h
Invoked when the user resizes the drawer or parent.
- (NSSize)drawerWillResizeContents:(NSDrawer *)sender toSize:(NSSize)contentSize
The drawer being resized.
The proposed new size of the drawer.
The size that the drawer should be resized to. To resize to a different size, simply return the desired size from this method; to avoid resizing, return the current size.
The receiver’s minimum and maximum size constraints have already been applied when this method is invoked. While the user is resizing an NSDrawer
or its parent, the delegate is sent a series of windowWillResize
messages as the NSDrawer
or parent window is dragged.
NSDrawer.h
These constants specify the possible states of a drawer.
typedef enum _NSDrawerState { NSDrawerClosedState = 0, NSDrawerOpeningState = 1, NSDrawerOpenState = 2, NSDrawerClosingState = 3 } NSDrawerState;
NSDrawerClosedState
The drawer is closed (not visible onscreen).
Available in Mac OS X v10.0 and later.
Declared in NSDrawer.h
.
NSDrawerOpeningState
The drawer is in the process of opening.
Available in Mac OS X v10.0 and later.
Declared in NSDrawer.h
.
NSDrawerOpenState
The drawer is open (visible onscreen).
Available in Mac OS X v10.0 and later.
Declared in NSDrawer.h
.
NSDrawerClosingState
The 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 NSDrawer
object 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
© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-05-23)