I'd like to make NSTableView
behave more like a traditional text editor, where hovering over the editable text area immediately shows the IBeamCursor
without having to click or double-click into the table cell first.
(I tried asking for a solution which changes the general behavior of the table view to achieve all of these things at once (How to make an NSTableView behave more like a text editor?), but such a solution doesn't seem to exist.)
So the question is now, where would be an appropriate place to put the code to change the mouse cursor? Or maybe, is there a way forward the mouse events to the underlying text field / text cell so that the regular cursor behavior is triggered that occurs with a single NSTextField
outside of an NSTableView
?
I'd prefer a solution for a view-based table view (as I want to put a custom view into one of the table columns), but solutions for a cell-based table view are also appreciated if there is no easy way with view-based ones.
So turns out the answer is as simple as adding the following to an NSTextField
subclass:
- (void)resetCursorRects {
[self addCursorRect:[self bounds] cursor:[NSCursor IBeamCursor]];
}
Based on the following answer referring to a plain NSTextField
, which happens to work for one embedded in a view-based NSTableView
as well: Can't change the mouse cursor of a NSTextField (which I found through @Willeke's hint of subclassing the NSTextField
)