Skip to content

Instantly share code, notes, and snippets.

@tonyarnold
Last active August 29, 2015 14:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonyarnold/fd587cad039a8cc30845 to your computer and use it in GitHub Desktop.
Save tonyarnold/fd587cad039a8cc30845 to your computer and use it in GitHub Desktop.
Detects when a text field's current editor is the parent window's first responder (the "view" here is an NSTableCellView subclass)
RACSignal *textFieldDidFocus = [[[[view rac_valuesForKeyPath:@keypath(view, textField.window.firstResponder) observer:view]
takeUntil:view.rac_willDeallocSignal] filter:^BOOL(id value) {
@strongify(view);
return [view.textField.currentEditor isEqualTo:value];
}]
mapReplace:view.textField];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment