Locks the focus on the view, so subsequent commands take effect in the view’s window and coordinate system.
- macOS 10.0–10.14Deprecated
If you don’t use a
display method to draw an
NSView object, you must invoke
lock before invoking methods that send commands to the window server, and must balance it with an
unlock message when finished.
Hiding or miniaturizing a one-shot window causes the backing store for that window to be released. (A one-shot window frees its window device when the window is hidden and another is created when it’s returned to the screen.) If you don’t use the standard display mechanism to draw, you should use
lock rather than
lock if there is a chance of drawing while the window is either miniaturized or hidden. This method throws an exception if the view is hidden or if drawing cannot happen for some other reason. To ensure that you can lock focus successfully, make sure the
can property is
true; you can also call
lock instead and use the return value of that method to determine if focus was obtained successfully.