Reputation: 21
I have an NSTableView
in which I need to be able to intercept keyboard events within an editable cell and replace the cell with strings. For example, press "a" and have the "a" intercepted and the value "Alpha" assigned when the table reloads. The actual situation is a bit more complex in that I'm also handling HID devices, but that's a whole other story. Suffice it to say, I just want to be able to go into edit mode and stop the keyboard-generated values from being displayed.
The latter part of this (displaying "Alpha") is easy, but I can't figure out the first part of the problem. If I subclass the table and make it first responder, I can receive the keyDown:
event, but once the user double-clicks on a cell and starts typing, this goes silent.
Since none of the other NSTableView
components (NSCell
, NSTextFieldCell
, etc) derive from NSResponder
, I'm assuming there is an NSTextField
buried in there somewhere.
So, what's the best way to filter text once the user goes into cell edit mode?
Upvotes: 1
Views: 254
Reputation: 21
As always happens: after working on this for eight hours, reading all the docs five times, and then resorting to the net, I find the answer five minutes later:
- (BOOL)textShouldBeginEditing:(NSText *)textObject.
Sorry to consume bandwidth.
Upvotes: 1