Search code examples
objective-cmacoscocoatooltipnsoutlineview

NSOutlineView and weird extra tooltip


In the datasource of my NSOutlineView I implement the method -toolTipForItem or something similar. It returns the appropriate NSString that should be displayed in the tooltip of the specified row.

The problem is that whenever I scroll, while the tooltip is being displayed, it shows yet another tooltip. This one from the NSTextFieldCell inside the outlineview. How do I disable that one. The cell is subclassed and I have disabled the exteriorFrame drawing in order to get rid of it, but now its just an empty box.


Solution

  • - (void)drawWithExpansionFrame:(NSRect)cellFrame inView:(NSView *)view
    {
        // no implementation
    }
    
    - (NSRect)expansionFrameWithFrame:(NSRect)cellFrame inView:(NSView *)view 
    {
        // fix the extra tooltip
        return NSZeroRect;
    }
    

    It only happens when the text inside the cell is being truncated, its trying to compensate for it by showing the tooltip. Disable with the code above.