Up

# NSView

### Authors

Scott Christley (`scottc@net-community.com`)
Felipe A. Rodriguez (`far@ix.netcom.com`)
Ovidiu Predescu (`ovidiu@net-community.com`)
Richard Frith-Macdonald (`richard@brainstorm.co.uk`)

> The view class which encapsulates all drawing functionality

Copyright: (C) (C) 1996 Free Software Foundation, Inc.

### Contents -

1. NSView
2. Software documentation for the NSView(PrivateMethods) category

# NSView

NSView is an abstract class which provides facilities for drawing in a window and receiving events. It is the superclass of many of the visual elements of the GUI.

In order to display itself, a view must be placed in a window (represented by an NSWindow object). Within the window is a hierarchy of NSViews, headed by the window's content view. Every other view in a window is a descendant of this view.

Subclasses can override -drawRect: in order to implement their appearance. Other methods of NSView and NSResponder can also be overridden to handle user generated events.

## NSView : NSResponder

> Declared in:
>   AppKit/NSView.h

> Standards:
> - MacOS-X
> - OpenStep
> - GNUstep

Description forthcoming.

Method summary

- -_invalidateCoordinates
- -_matrixFromWindow
- -_matrixToWindow
- -_rebuildCoordinates
- +defaultMenu
- +focusView
- -acceptsFirstMouse:
- -addCursorRect:cursor:
- -addSubview:
- -addSubview:positioned:relativeTo:
- -addToPageSetup
- -addToolTipRect:owner:userData:
- -addTrackingRect:owner:userData:assumeInside:
- -adjustPageHeightNew:top:bottom:limit:
- -adjustPageWidthNew:left:right:limit:
- -adjustScroll:
- -allocateGState
- -ancestorSharedWithView:
- -autoresizesSubviews
- -autoresizingMask
- -autoscroll:
- -beginDocument
- -beginPage:label:bBox:fonts:
- -beginPageInRect:atPlacement:
- -beginPageSetupRect:placement:
- -beginPrologueBBox:creationDate:createdBy:fonts:forWhom:pages:title:
- -beginSetup
- -beginTrailer
- -bounds
- -boundsRotation
- -canDraw
- -centerScanRect:
- -convertPoint:fromView:
- -convertPoint:toView:
- -convertRect:fromView:
- -convertRect:toView:
- -convertSize:fromView:
- -convertSize:toView:
- -dataWithEPSInsideRect:
- -dataWithPDFInsideRect:
- -didAddSubview:
- -discardCursorRects
- -display
- -displayIfNeeded
- -displayIfNeededIgnoringOpacity
- -displayIfNeededInRect:
- -displayIfNeededInRectIgnoringOpacity:
- -displayRect:
- -displayRectIgnoringOpacity:
- -dragFile:fromRect:slideBack:event:
- -dragImage:at:offset:event:pasteboard:source:slideBack:
- -drawPageBorderWithSize:
- -drawRect:
- -drawSheetBorderWithSize:
- -enclosingScrollView
- -endDocument
- -endHeaderComments
- -endPage
- -endPageSetup
- -endPrologue
- -endSetup
- -endTrailer
- -fax:
- -frame
- -frameRotation
- -gState
- -heightAdjustLimit
- -hitTest:
- -initWithFrame:
- -isDescendantOf:
- -isFlipped
- -isOpaque
- -isRotatedFromBase
- -isRotatedOrScaledFromBase
- -knowsPageRange:
- -knowsPagesFirst:last:
- -locationOfPrintRect:
- -lockFocus
- -lockFocusIfCanDraw
- -lockFocusInRect:
- -menuForEvent:
- -mouse:inRect:
- -needsDisplay
- -needsPanelToBecomeKey
- -nextKeyView
- -nextValidKeyView
- -opaqueAncestor
- -performKeyEquivalent:
- -performMnemonic:
- -postsBoundsChangedNotifications
- -postsFrameChangedNotifications
- -previousKeyView
- -previousValidKeyView
- -print:
- -printJobTitle
- -rectForPage:
- -reflectScrolledClipView:
- -registerForDraggedTypes:
- -releaseGState
- -removeAllToolTips
- -removeCursorRect:cursor:
- -removeFromSuperview
- -removeFromSuperviewWithoutNeedingDisplay
- -removeSubview:
- -removeToolTip:
- -removeTrackingRect:
- -renewGState
- -replaceSubview:with:
- -resetCursorRects
- -resizeSubviewsWithOldSize:
- -resizeWithOldSuperviewSize:
- -rotateByAngle:
- -scaleUnitSquareToSize:
- -scrollClipView:toPoint:
- -scrollPoint:
- -scrollRect:by:
- -scrollRectToVisible:
- -setAutoresizesSubviews:
- -setAutoresizingMask:
- -setBounds:
- -setBoundsOrigin:
- -setBoundsRotation:
- -setBoundsSize:
- -setFrame:
- -setFrameOrigin:
- -setFrameRotation:
- -setFrameSize:
- -setNeedsDisplay:
- -setNeedsDisplayInRect:
- -setNextKeyView:
- -setPostsBoundsChangedNotifications:
- -setPostsFrameChangedNotifications:
- -setPreviousKeyView:
- -setToolTip:
- -setUpGState
- -shouldDelayWindowOrderingForEvent:
- -shouldDrawColor
- -sortSubviewsUsingFunction:context:
- -subviews
- -superview
- -tag
- -toolTip
- -translateOriginToPoint:
- -unlockFocus
- -unregisterDraggedTypes
- -viewDidMoveToSuperview
- -viewDidMoveToWindow
- -viewWillMoveToSuperview:
- -viewWillMoveToWindow:
- -viewWithTag:
- -visibleRect
- -widthAdjustLimit
- -willRemoveSubview:
- -window
- -writeEPSInsideRect:toPasteboard:
- -writePDFInsideRect:toPasteboard:

### defaultMenu

+ (NSMenu*) defaultMenu;

Returns the default menu to be used for instances of the current class; if no menu has been set through setMenu: this default menu will be used.

NSView's implementation returns `nil` . You should override this method if you want all instances of your custom view to use the same menu.

### focusView

+ (NSView*) focusView;

Return the view at the top of graphics contexts stack or `nil` if none is focused.

### acceptsFirstMouse:

- (BOOL) acceptsFirstMouse: (NSEvent*)theEvent;

Returns `YES` if the view object will accept the first click received when in an inactive window, and `NO` otherwise.

### addCursorRect:cursor:

- (void) addCursorRect: (NSRect)aRect cursor: (NSCursor*)anObject;

Description forthcoming.

### addSubview:

- (void) addSubview: (NSView*)aView;

Adds aView as a subview of the receiver.

### addSubview:positioned:relativeTo:

- (void) addSubview: (NSView*)aView positioned: (NSWindowOrderingMode)place relativeTo: (NSView*)otherView;

Description forthcoming.

### addToPageSetup

- (void) addToPageSetup;

Description forthcoming.

### addToolTipRect:owner:userData:

- (NSToolTipTag) addToolTipRect: (NSRect)aRect owner: (id)anObject userData: (void*)data;

Description forthcoming.

### addTrackingRect:owner:userData:assumeInside:

- (NSTrackingRectTag) addTrackingRect: (NSRect)aRect owner: (id)anObject userData: (void*)data assumeInside: (BOOL)flag;

Description forthcoming.

### adjustPageHeightNew:top:bottom:limit:

- (void) adjustPageHeightNew: (float*)newBottom top: (float)oldTop bottom: (float)oldBottom limit: (float)bottomLimit;

Description forthcoming.

### adjustPageWidthNew:left:right:limit:

- (void) adjustPageWidthNew: (float*)newRight left: (float)oldLeft right: (float)oldRight limit: (float)rightLimit;

Description forthcoming.

### adjustScroll:

- (NSRect) adjustScroll: (NSRect)newVisible;

Description forthcoming.

### allocateGState

- (void) allocateGState;

Tell the view to maintain a private gstate object which encapsulates all the information about drawing, such as coordinate transforms, line widths, etc. If you do not invoke this method, a gstate object is constructed each time the view is lockFocused. Allocating a private gstate may improve the performance of views that are focused a lot and have a lot of customized drawing parameters.

View subclasses should override the setUpGstate method to set these custom parameters.

### ancestorSharedWithView:

- (NSView*) ancestorSharedWithView: (NSView*)aView;

Returns self if aView is the receiver or aView is a subview of the receiver, the ancestor view shared by aView and the receiver if any, or aView if it is an ancestor of the receiver, otherwise returns `nil`.

### autoresizesSubviews

- (BOOL) autoresizesSubviews;

Description forthcoming.

### autoresizingMask

- (unsigned int) autoresizingMask;

Description forthcoming.

### autoscroll:

- (BOOL) autoscroll: (NSEvent*)theEvent;

Description forthcoming.

### beginDocument

- (void) beginDocument;

Writes header and job information for the PostScript document. This includes at a minimum, PostScript header information. It may also include job setup information if the output is intended for a printer (i.e. not an EPS file). Most of the information for writing the header comes from the NSPrintOperation and NSPrintInfo objects associated with the current print operation. There isn't normally anything that the program needs to override at the beginning of a document, although if there is additional setup that needs to be done, you can override the NSView's methods endHeaderComments, endPrologue, beginSetup, and/or endSetup. This method calls the above methods in the listed order before or after writing the required information. For an EPS operation, the beginSetup and endSetup methods aren't used.

### beginPage:label:bBox:fonts:

- (void) beginPage: (int)ordinalNum label: (NSString*)aString bBox: (NSRect)pageRect fonts: (NSString*)fontNames;

Description forthcoming.

### beginPageInRect:atPlacement:

- (void) beginPageInRect: (NSRect)aRect atPlacement: (NSPoint)location;

Description forthcoming.

### beginPageSetupRect:placement:

- (void) beginPageSetupRect: (NSRect)aRect placement: (NSPoint)location;

Description forthcoming.

### beginPrologueBBox:creationDate:createdBy:fonts:forWhom:pages:title:

- (void) beginPrologueBBox: (NSRect)boundingBox creationDate: (NSString*)dateCreated createdBy: (NSString*)anApplication fonts: (NSString*)fontNames forWhom: (NSString*)user pages: (int)numPages title: (NSString*)aTitle;

Description forthcoming.

### beginSetup

- (void) beginSetup;

Description forthcoming.

### beginTrailer

- (void) beginTrailer;

Description forthcoming.

### bounds

- (NSRect) bounds;

Description forthcoming.

### boundsRotation

- (float) boundsRotation;

Description forthcoming.

### canDraw

- (BOOL) canDraw;

Description forthcoming.

### centerScanRect:

- (NSRect) centerScanRect: (NSRect)aRect;

Description forthcoming.

### convertPoint:fromView:

- (NSPoint) convertPoint: (NSPoint)aPoint fromView: (NSView*)aView;

Description forthcoming.

### convertPoint:toView:

- (NSPoint) convertPoint: (NSPoint)aPoint toView: (NSView*)aView;

Description forthcoming.

### convertRect:fromView:

- (NSRect) convertRect: (NSRect)aRect fromView: (NSView*)aView;

Description forthcoming.

### convertRect:toView:

- (NSRect) convertRect: (NSRect)aRect toView: (NSView*)aView;

Description forthcoming.

### convertSize:fromView:

- (NSSize) convertSize: (NSSize)aSize fromView: (NSView*)aView;

Description forthcoming.

### convertSize:toView:

- (NSSize) convertSize: (NSSize)aSize toView: (NSView*)aView;

Description forthcoming.

### dataWithEPSInsideRect:

- (NSData*) dataWithEPSInsideRect: (NSRect)aRect;

Description forthcoming.

### dataWithPDFInsideRect:

- (NSData*) dataWithPDFInsideRect: (NSRect)aRect;

Description forthcoming.

### didAddSubview:

- (void) didAddSubview: (NSView*)subview;

Description forthcoming.

### discardCursorRects

- (void) discardCursorRects;

Description forthcoming.

### display

- (void) display;

Description forthcoming.

### displayIfNeeded

- (void) displayIfNeeded;

Description forthcoming.

### displayIfNeededIgnoringOpacity

- (void) displayIfNeededIgnoringOpacity;

Description forthcoming.

### displayIfNeededInRect:

- (void) displayIfNeededInRect: (NSRect)aRect;

Description forthcoming.

### displayIfNeededInRectIgnoringOpacity:

- (void) displayIfNeededInRectIgnoringOpacity: (NSRect)aRect;

Description forthcoming.

### displayRect:

- (void) displayRect: (NSRect)aRect;

Causes the area of the view specified by aRect to be displayed. This is done by moving up the view hierarchy until an opaque view is found, then asking that view to update the appropriate area.

### displayRectIgnoringOpacity:

- (void) displayRectIgnoringOpacity: (NSRect)aRect;

Description forthcoming.

### dragFile:fromRect:slideBack:event:

- (BOOL) dragFile: (NSString*)filename fromRect: (NSRect)rect slideBack: (BOOL)slideFlag event: (NSEvent*)event;

Description forthcoming.

### dragImage:at:offset:event:pasteboard:source:slideBack:

- (void) dragImage: (NSImage*)anImage at: (NSPoint)viewLocation offset: (NSSize)initialOffset event: (NSEvent*)event pasteboard: (NSPasteboard*)pboard source: (id)sourceObject slideBack: (BOOL)slideFlag;

Description forthcoming.

### drawPageBorderWithSize:

- (void) drawPageBorderWithSize: (NSSize)borderSize;

Description forthcoming.

### drawRect:

- (void) drawRect: (NSRect)rect;

This method is invoked to handle drawing inside the view. The default NSView's implementation does nothing; subclasses might override it to draw something inside the view. Since NSView's implementation is guaranteed to be empty, you should not call super's implementation when you override it in subclasses. drawRect: is invoked when the focus has already been locked on the view; you can use arbitrary postscript functions in drawRect: to draw inside your view; the coordinate system in which you draw is the view's own coordinate system (this means for example that you should refer to the rectangle covered by the view using its bounds, and not its frame). The argument of drawRect: is the rectangle which needs to be redrawn. In a lossy implementation, you can ignore the argument and redraw the whole view; if you are aiming at performance, you may want to redraw only what is inside the rectangle which needs to be redrawn; this usually improves drawing performance considerably.

### drawSheetBorderWithSize:

- (void) drawSheetBorderWithSize: (NSSize)borderSize;

Description forthcoming.

### enclosingScrollView

- (NSScrollView*) enclosingScrollView;

Description forthcoming.

### endDocument

- (void) endDocument;

Description forthcoming.

### endHeaderComments

- (void) endHeaderComments;

Description forthcoming.

### endPage

- (void) endPage;

Description forthcoming.

### endPageSetup

- (void) endPageSetup;

Description forthcoming.

### endPrologue

- (void) endPrologue;

Description forthcoming.

### endSetup

- (void) endSetup;

Description forthcoming.

### endTrailer

- (void) endTrailer;

Description forthcoming.

### fax:

- (void) fax: (id)sender;

Description forthcoming.

### frame

- (NSRect) frame;

Description forthcoming.

### frameRotation

- (float) frameRotation;

Description forthcoming.

### gState

- (int) gState;

Returns an identifier that represents the view's gstate object, which is used to encapsulate drawing information about the view. Most of the time a gstate object is created from scratch when the view is focused, so if the view is not currently focused or allocateGState has not been called, then this method will

### heightAdjustLimit

- (float) heightAdjustLimit;

Description forthcoming.

### hitTest:

- (NSView*) hitTest: (NSPoint)aPoint;

Returns the subview, lowest in the receiver's hierarchy, which contains aPoint, or `nil` if there is no such view.

### initWithFrame:

- (id) initWithFrame: (NSRect)frameRect;

Description forthcoming.

### isDescendantOf:

- (BOOL) isDescendantOf: (NSView*)aView;

Returns `YES` if aView is an ancestor of the receiver.

### isFlipped

- (BOOL) isFlipped;

Description forthcoming.

### isOpaque

- (BOOL) isOpaque;

Description forthcoming.

### isRotatedFromBase

- (BOOL) isRotatedFromBase;

Description forthcoming.

### isRotatedOrScaledFromBase

- (BOOL) isRotatedOrScaledFromBase;

Description forthcoming.

### knowsPageRange:

- (BOOL) knowsPageRange: (NSRange*)range;

Description forthcoming.

### knowsPagesFirst:last:

- (BOOL) knowsPagesFirst: (int*)firstPageNum last: (int*)lastPageNum;

Description forthcoming.

### locationOfPrintRect:

- (NSPoint) locationOfPrintRect: (NSRect)aRect;

Description forthcoming.

### lockFocus

- (void) lockFocus;

Description forthcoming.

### lockFocusIfCanDraw

- (BOOL) lockFocusIfCanDraw;

Description forthcoming.

### lockFocusInRect:

- (void) lockFocusInRect: (NSRect)rect;

Description forthcoming.

### menuForEvent:

- (NSMenu*) menuForEvent: (NSEvent*)theEvent;

Returns the menu that it appropriates for the given event. NSView's implementation returns the default menu of the view.

This methods is intended to be overriden so that it can return a context-sensitive for appropriate mouse's events. ((although it seems it can be used for any kind of event)

This method is used by NSView's rightMouseDown: method, and the returned NSMenu is displayed as a context menu

Use of this method is discouraged in GNUstep as it breaks many user interface guidelines. At the very least, menu items that appear in a context sensitive menu should also always appear in a normal menu. Otherwise, users are faced with an inconsistant interface where the menu items they want are only available in certain (possibly unknown) cases, making it difficult for the user to understand how the application operates

see [NSResponder -menu], [NSResponder -setMenu:], [NSView +defaultMenu] and [NSView -menu].

### mouse:inRect:

- (BOOL) mouse: (NSPoint)aPoint inRect: (NSRect)aRect;

Returns whether or not aPoint lies within aRect.

### needsDisplay

- (BOOL) needsDisplay;

Description forthcoming.

### needsPanelToBecomeKey

- (BOOL) needsPanelToBecomeKey;

Description forthcoming.

### nextKeyView

- (NSView*) nextKeyView;

Returns the next view after the receiver in the key view chain.
Returns `nil` if there is no view after the receiver.
The next view is set up using the -setNextKeyView: method.
The key view chain is used to determine the order in which views become first responder when using keyboard navigation.

### nextValidKeyView

- (NSView*) nextValidKeyView;

Returns the first available view after the receiver which is actually able to become first responder. See -nextKeyView and [NSResponder -acceptsFirstResponder]

### opaqueAncestor

- (NSView*) opaqueAncestor;

Description forthcoming.

### performKeyEquivalent:

- (BOOL) performKeyEquivalent: (NSEvent*)theEvent;

Description forthcoming.

### performMnemonic:

- (BOOL) performMnemonic: (NSString*)aString;

Description forthcoming.

### postsBoundsChangedNotifications

- (BOOL) postsBoundsChangedNotifications;

Description forthcoming.

### postsFrameChangedNotifications

- (BOOL) postsFrameChangedNotifications;

Description forthcoming.

### previousKeyView

- (NSView*) previousKeyView;

Returns the view before the receiver in the key view chain.
Returns `nil` if there is no view before the receiver in the chain.
The previous view of the receiver was set up by passing it as the argument to a call of -setNextKeyView: on that view.
The key view chain is used to determine the order in which views become first responder when using keyboard navigation.

### previousValidKeyView

- (NSView*) previousValidKeyView;

Returns the first available view before the receiver which is actually able to become first responder. See -nextKeyView and [NSResponder -acceptsFirstResponder]

### print:

- (void) print: (id)sender;

Description forthcoming.

### printJobTitle

- (NSString*) printJobTitle;

Description forthcoming.

### rectForPage:

- (NSRect) rectForPage: (int)page;

Description forthcoming.

### reflectScrolledClipView:

- (void) reflectScrolledClipView: (NSClipView*)aClipView;

Description forthcoming.

### registerForDraggedTypes:

- (void) registerForDraggedTypes: (NSArray*)newTypes;

Registers the fact that the receiver should accept dragged data of any of the specified types. You need to do this if you want your view to support drag and drop.

### releaseGState

- (void) releaseGState;

Frees the gstate object, if there is one. Note that the next time the view is lockFocused, the gstate will be allocated again.

### removeAllToolTips

- (void) removeAllToolTips;

Description forthcoming.

### removeCursorRect:cursor:

- (void) removeCursorRect: (NSRect)aRect cursor: (NSCursor*)anObject;

Description forthcoming.

### removeFromSuperview

- (void) removeFromSuperview;

Removes the receiver from its superviews list of subviews, by invoking the superviews -removeSubview: method, and marks the rectangle that the reciever occupied in the superview as needing redisplay.

This is dangerous to use during display, since it alters the rectangles needing display. In this case, you can use the -removeFromSuperviewWithoutNeedingDisplay method instead.

### removeFromSuperviewWithoutNeedingDisplay

- (void) removeFromSuperviewWithoutNeedingDisplay;

Removes the receiver from its superviews list of subviews, by invoking the superviews [-removeSubview:] method.

### removeSubview:

- (void) removeSubview: (NSView*)aView;

Removes aSubview from the receivers list of subviews and from the responder chain.

Also invokes -viewWillMoveToWindow: on aView with a `nil` argument, to handle removal of aView (and recursively, its children) from its window - performing tidyup by invalidating cursor rects etc.

### removeToolTip:

- (void) removeToolTip: (NSToolTipTag)tag;

Description forthcoming.

### removeTrackingRect:

- (void) removeTrackingRect: (NSTrackingRectTag)tag;

Description forthcoming.

### renewGState

- (void) renewGState;

Invalidates the view's gstate object so it will be set up again using setUpGState the next time the view is focused.

### replaceSubview:with:

- (void) replaceSubview: (NSView*)oldView with: (NSView*)newView;

Removes oldView from the receiver and places newView in its place.

### resetCursorRects

- (void) resetCursorRects;

Description forthcoming.

### resizeSubviewsWithOldSize:

- (void) resizeSubviewsWithOldSize: (NSSize)oldSize;

Description forthcoming.

### resizeWithOldSuperviewSize:

- (void) resizeWithOldSuperviewSize: (NSSize)oldSize;

Description forthcoming.

### rotateByAngle:

- (void) rotateByAngle: (float)angle;

Description forthcoming.

### scaleUnitSquareToSize:

- (void) scaleUnitSquareToSize: (NSSize)newSize;

Description forthcoming.

### scrollClipView:toPoint:

- (void) scrollClipView: (NSClipView*)aClipView toPoint: (NSPoint)aPoint;

Description forthcoming.

### scrollPoint:

- (void) scrollPoint: (NSPoint)aPoint;

Description forthcoming.

### scrollRect:by:

- (void) scrollRect: (NSRect)aRect by: (NSSize)delta;

Description forthcoming.

### scrollRectToVisible:

- (BOOL) scrollRectToVisible: (NSRect)aRect;

Description forthcoming.

### setAutoresizesSubviews:

- (void) setAutoresizesSubviews: (BOOL)flag;

Description forthcoming.

### setAutoresizingMask:

- (void) setAutoresizingMask: (unsigned int)mask;

Description forthcoming.

### setBounds:

- (void) setBounds: (NSRect)aRect;

Description forthcoming.

### setBoundsOrigin:

- (void) setBoundsOrigin: (NSPoint)newOrigin;

Description forthcoming.

### setBoundsRotation:

- (void) setBoundsRotation: (float)angle;

Description forthcoming.

### setBoundsSize:

- (void) setBoundsSize: (NSSize)newSize;

Description forthcoming.

### setFrame:

- (void) setFrame: (NSRect)frameRect;

Description forthcoming.

### setFrameOrigin:

- (void) setFrameOrigin: (NSPoint)newOrigin;

Description forthcoming.

### setFrameRotation:

- (void) setFrameRotation: (float)angle;

Description forthcoming.

### setFrameSize:

- (void) setFrameSize: (NSSize)newSize;

Description forthcoming.

### setNeedsDisplay:

- (void) setNeedsDisplay: (BOOL)flag;

As an exception to the general rules for threads and gui, this method is thread-safe and may be called from any thread. Display will always be done in the main thread. (Note that other methods are in general not thread-safe; if you want to access other properties of views from multiple threads, you need to provide the synchronization.)

### setNeedsDisplayInRect:

- (void) setNeedsDisplayInRect: (NSRect)invalidRect;

Inform the view system that the specified rectangle is invalid and requires updating. This automatically informs any superviews of any updating they need to do. As an exception to the general rules for threads and gui, this method is thread-safe and may be called from any thread. Display will always be done in the main thread. (Note that other methods are in general not thread-safe; if you want to access other properties of views from multiple threads, you need to provide the synchronization.)

### setNextKeyView:

- (void) setNextKeyView: (NSView*)aView;

The effect of the -setNextKeyView: method is to set aView to be the value returned by subsequent calls to the receivers -nextKeyView method. This also has the effect of setting the previous key view of aView, so that subsequent calls to its -previousKeyView method will return the receiver.

As a special case, if you pass `nil` as aView then the -previousKeyView of the receivers current -nextKeyView is set to `nil` as well as the receivers -nextKeyView being set to `nil`.
This behavior provides MacOS-X compatibility.

If you pass a non-view object other than `nil`, an NSInternaInconsistencyException is raised.

NB This method does NOT cause aView to be retained, and if aView is deallocated, the [NSView -dealloc] method will automatically remove it from the key view chain it is in.

For keyboard navigation, views are linked together in a chain, so that the current first responder view can be changed by stepping backward and forward in that chain. This is the method for building and modifying that chain.

The MacOS-X documentation refers to this chain as a loop, but the actual implementation is not a loop at all (except as a special case when you make the chain into a loop). In fact, while each view may have only zero or one next view, and zero or one previous view, several views may have their next view set to a single view and/or their previous views set to a single view. So the actual setup is a directed graph rather than a loop.

While a directed graph is a very powerful and flexible way of managing the way views get keyboard focus in response to tabs etc, it can be confusing if misused. It is probably best therefore, to set your views up as a single loop within each window.

       [a setNextKeyView: b];
       [b setNextKeyView: c];
       [c setNextKeyView: d];
       [d setNextKeyView: a];

### setPostsBoundsChangedNotifications:

- (void) setPostsBoundsChangedNotifications: (BOOL)flag;

Description forthcoming.

### setPostsFrameChangedNotifications:

- (void) setPostsFrameChangedNotifications: (BOOL)flag;

Description forthcoming.

### setPreviousKeyView:

- (void) setPreviousKeyView: (NSView*)aView;

GNUstep addition... a conveninece method to insert a view in the key view chain before the receiver, using the -previousKeyView and -setNextKeyView: methods.

### setToolTip:

- (void) setToolTip: (NSString*)string;

Description forthcoming.

### setUpGState

- (void) setUpGState;

Description forthcoming.

### shouldDelayWindowOrderingForEvent:

- (BOOL) shouldDelayWindowOrderingForEvent: (NSEvent*)anEvent;

Description forthcoming.

### shouldDrawColor

- (BOOL) shouldDrawColor;

Description forthcoming.

### sortSubviewsUsingFunction:context:

- (void) sortSubviewsUsingFunction: (int(*)(id,id,void*))compare context: (void*)context;

Description forthcoming.

### subviews

- (NSArray*) subviews;

Description forthcoming.

### superview

- (NSView*) superview;

Description forthcoming.

### tag

- (int) tag;

Description forthcoming.

### toolTip

- (NSString*) toolTip;

Description forthcoming.

### translateOriginToPoint:

- (void) translateOriginToPoint: (NSPoint)point;

Description forthcoming.

### unlockFocus

- (void) unlockFocus;

Description forthcoming.

### unregisterDraggedTypes

- (void) unregisterDraggedTypes;

Description forthcoming.

### viewDidMoveToSuperview

- (void) viewDidMoveToSuperview;

Description forthcoming.

### viewDidMoveToWindow

- (void) viewDidMoveToWindow;

Description forthcoming.

### viewWillMoveToSuperview:

- (void) viewWillMoveToSuperview: (NSView*)newSuper;

Notifies the receiver that its superview is being changed to newSuper.

### viewWillMoveToWindow:

- (void) viewWillMoveToWindow: (NSWindow*)newWindow;

Notifies the receiver that it will now be a view of newWindow. Note, this method is also used when removing a view from a window (in which case, newWindow is `nil`) to let all the subviews know that they have also been removed from the window.

### viewWithTag:

- (id) viewWithTag: (int)aTag;

Description forthcoming.

### visibleRect

- (NSRect) visibleRect;

Description forthcoming.

### widthAdjustLimit

- (float) widthAdjustLimit;

Description forthcoming.

### willRemoveSubview:

- (void) willRemoveSubview: (NSView*)subview;

Description forthcoming.

### window

- (NSWindow*) window;

Returns the window in which the receiver resides.

### writeEPSInsideRect:toPasteboard:

- (void) writeEPSInsideRect: (NSRect)rect toPasteboard: (NSPasteboard*)pasteboard;

Description forthcoming.

### writePDFInsideRect:toPasteboard:

- (void) writePDFInsideRect: (NSRect)aRect toPasteboard: (NSPasteboard*)pboard;

Description forthcoming.

# Software documentation for the NSView(PrivateMethods) category

## NSView(PrivateMethods)

> Declared in:
>   AppKit/NSView.h

> Standards:
> - NotOpenStep
> - NotMacOS-X
> - GNUstep

Warning this category is private, which means that the methods are for internal use by the package. You should not use them in external code.

Method summary

- -_invalidateCoordinates
- -_matrixFromWindow
- -_matrixToWindow
- -_rebuildCoordinates

### _invalidateCoordinates

- (void) _invalidateCoordinates;

Warning the underscore at the start of the name of this method indicates that it is private, for internal use only, and you should not use the method in your code.

### _matrixFromWindow

- (NSAffineTransform*) _matrixFromWindow;

Warning the underscore at the start of the name of this method indicates that it is private, for internal use only, and you should not use the method in your code.

### _matrixToWindow

- (NSAffineTransform*) _matrixToWindow;

Warning the underscore at the start of the name of this method indicates that it is private, for internal use only, and you should not use the method in your code.

### _rebuildCoordinates

- (void) _rebuildCoordinates;

Warning the underscore at the start of the name of this method indicates that it is private, for internal use only, and you should not use the method in your code.

Up