How can I implement modified behavior when the user clicks Ctrl+A (select all).
I tried modifying the keyDown:
event but it didn't seem to catch the event.
Asked
Active
Viewed 169 times
0
-
5Do you mean ⌘+A, or would like the ability to use ctrl+A? – Joe Apr 18 '12 at 19:30
-
You need to ensure that the view controller is first responder, else it will never see those key down events. – Perception Apr 18 '12 at 19:41
1 Answers
3
⌘+A is generally mapped to selectAll:
on the first responder. You should be able to simply implement the selectAll:
method on any responder in the chain and it'll "just work".

Rob Keniger
- 45,830
- 6
- 101
- 134

bbum
- 162,346
- 23
- 271
- 359
-
1And standard views such as NSTextView will already respond to `selectAll:` and friends, so for text selection, you don't need to do anything. – Peter Hosey Apr 19 '12 at 01:47
-
`keyDown:` is called and when I log the window's first responder in that, it's the same as this view but `selectAll:` isn't called. Wonder why. – trss Apr 09 '13 at 06:41
-
Got it, that's because I'm not calling `super`'s implementation in `keyDown:`. – trss Apr 09 '13 at 06:44
-
Responded too early. `selectAll:` doesn't get called even when `super`'s implementation of `keyDown:` is called with the same event. – trss Apr 09 '13 at 06:55
-