---
title: lockFocusIfCanDraw()
framework: appkit
role: symbol
role_heading: Instance Method
path: appkit/nsview/lockfocusifcandraw()
---

# lockFocusIfCanDraw()

Locks the focus to the view atomically if the canDraw method returns true and returns the value of canDraw.

## Declaration

```swift
func lockFocusIfCanDraw() -> Bool
```

## Discussion

Discussion Your thread will not be preempted by other threads between the canDraw method and the lock. This method fails to lock focus and returns false, when the view is hidden and the current context is drawing to the screen (as opposed to a printing context).

## See Also

### Methods

- [lockFocus()](appkit/nsview/lockfocus().md)
- [lockFocusIfCanDraw(in:)](appkit/nsview/lockfocusifcandraw(in:).md)
- [unlockFocus()](appkit/nsview/unlockfocus().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)
