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

# lockFocusIfCanDraw(in:)

Locks the focus to the view atomically if drawing can occur in the specified graphics context.

## Declaration

```swift
func lockFocusIfCanDraw(in context: NSGraphicsContext) -> Bool
```

## Parameters

- `context`: The graphics context in which drawing might occur. See the discussion for the implications of the type of context.

## Return Value

Return Value true if successful; otherwise, returns false.

## See Also

### Methods

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