The problem is that the white background is drawn by the NSTableView when it is sent -editColumn: row: withEvent: select :. It fills the cell rectangle + [NSColor textBackgroundColor].
If there is a public API for overriding the current parameter for named colors from the developerโs color space, we can set it inside the -editColumn: row: withEvent: select: override or the like. I do not remember such an API (pointers are evaluated). SEE ALSO: I only tested this code on Snow Leopard (even the addition to the Leopard SDK below). Check the code for the actual SDKs and runtimes that you intend to support.
NSTableView has a private accessory that it uses for fill color, but this property is read-only. There is no setter, so we cannot just change the value on a standard NSTableView. We must subclass it. (Since you want the same behavior in outlineView and NSOutlineView to already be a subclass of NSTableView, we are going to subclass NSOutlineView. But, besides the superclass, the code is identical.)
@interface ASCOutlineView : NSOutlineView { } @end @implementation ASCOutlineView - _textBackgroundColor { return ([NSColor clearColor]); } @end
Everything seems to need to be prevented so that this bright white block destroys your HUD when editing table cells in Snow Leopard.
Applications compiled against the Leopard SDK need a little extra support. Leopard tableViews may have some hard-coded rendering properties, so we need to override the selection method.
NSTextFieldCells are actually wrappers for NSTextView, so they can be used inside controls. Usually they have the same textView instance controlled by the window (or its subclass, panel, in this case). NSTableView modifies the settings of NSTextFieldCell to match the system user interface settings for editing data. Mostly. NSTextFieldCell then passes these settings to NSTextView. At any point in this pipeline, we can override a method or two to change the values โโof these properties according to our own user interface.
I use - [NSTextFieldCell setDrawsBackground:], because it takes a little effort to fix it. It is also important to preserve the internal state in accordance with the effect that we hope to achieve if any other object may depend on this state.
@interface ASCTextFieldCell : NSTextFieldCell { } @end @implementation ASCTextFieldCell - (void)setDrawsBackground: (BOOL)flag { [super setDrawsBackground: NO]; } @end
And preventing the appearance of the focus ring while the cell being edited is just a matter of changing the setting of its type of focus ring. Frustratedly, IB does not provide access to this property, so it must be done programmatically:
for(eachColumn in [hudOutlineView tableColumns]) { columnCell = [[ASCTextFieldCell alloc] initTextCell: @""]; [eachColumn setDataCell: columnCell]; if([columnCell respondsToSelector: @selector(setFocusRingType:)] != NO) [(NSTextFieldCell *)columnCell setFocusRingType: NSFocusRingTypeNone]; }