---
title: unlockFocus()
framework: appkit
role: symbol
role_heading: Instance Method
path: appkit/nsview/unlockfocus()
---

# unlockFocus()

Unlocks focus from the current view.

## Declaration

```swift
func unlockFocus()
```

## Discussion

Discussion Call this method after a previous call to the lockFocus(), lockFocusIfCanDraw(), or lockFocusIfCanDraw(in:) method of this view object. Doing so releases focus from the current view and returns it back to the previously focused view, if any. This method raises an NSInvalidArgumentException if the current view does not have the focus.

## See Also

### Methods

- [lockFocus()](appkit/nsview/lockfocus().md)
- [lockFocusIfCanDraw()](appkit/nsview/lockfocusifcandraw().md)
- [lockFocusIfCanDraw(in:)](appkit/nsview/lockfocusifcandraw(in:).md)
- [scroll(_:by:)](appkit/nsview/scroll(_:by:).md)
- [shouldDrawColor()](appkit/nsview/shoulddrawcolor().md)
- [allocateGState()](appkit/nsview/allocategstate().md)
- [gState()](appkit/nsview/gstate().md)
- [setUpGState()](appkit/nsview/setupgstate().md)
- [renewGState()](appkit/nsview/renewgstate().md)
- [releaseGState()](appkit/nsview/releasegstate().md)
- [dragFile(_:from:slideBack:event:)](appkit/nsview/dragfile(_:from:slideback:event:).md)
- [dragPromisedFiles(ofTypes:from:source:slideBack:event:)](appkit/nsview/dragpromisedfiles(oftypes:from:source:slideback:event:).md)
