Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8030963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:56:31+00:00 2026-06-05T00:56:31+00:00

I have a question about implementing a few specific behaviors in NSTableViews/NSOutlineViews. WHAT I’M

  • 0

I have a question about implementing a few specific behaviors in NSTableViews/NSOutlineViews.

WHAT I’M TRYING TO ACHIEVE:

I’m trying to create an NSOutlineView that mimics the behavior of Photoshop’s layers panel (except the “Layers” column is hierarchical). My outlineview is a 3-column table, with a “Layer” column, “Visbility” column, and a “Lock” column. I’ve implemented the “visibility” and “lock” columns as NSImageCells, and the “layer” column as a custom text and image cell.

Specifically, here’s the behavior I’m struggling to implement:

  • Just like Photoshop, the user should be able to click on a visibility (eyeball) icon and drag up or down to different rows to turn the other row visibilities “on” or “off” depending on the visibility of the first row clicked…exactly how Photoshop does hiding and showing of layers. Note that autoscroll should be supported for cases when there are many rows in the table.

  • Just like Photoshop, when one or more rows in the “Layer” column is selected, the visibility/lock columns should NOT have the highlight bar behind them (that is, the row highlight should not pass through their columns).

  • Clicking and/or dragging in the “visibility” or “lock” columns should not change the selection of the table…only their states as described above.

I’ve been banging my head against the wall for a week trying to get this to work. I’ve read the Controls & Cells Programming Guide, Table View Programming Guide, Class references for NSCell, NSActionCell, NSTableView, NSControl, NSOutlineView, and the Protocol references for NSOutlineViewDelegate and NSOutlineViewDataSource…and have been trying different approaches all week…and I’m just not figuring this one out.

Can someone steer me in the right direction? Thanks in advance for the help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T00:56:33+00:00Added an answer on June 5, 2026 at 12:56 am

    Through some additional web searching and experimentation, I can answer most of my own questions:

    HIGHLIGHTING ONLY THE FIRST COLUMN IN THE NSOUTLINEVIEW

    I was able to have the selection highlight appear only over the selected rows of the first column by subclassing NSOutlineView and implementing

    - (void)highlightSelectionInClipRect:(NSRect)clipRect
    {
        NSRange visibleRowIndexes = [self rowsInRect:clipRect];
        NSIndexSet *selectedRowIndexes = [self selectedRowIndexes];
    
        NSInteger currentRow = visibleRowIndexes.location;
        NSInteger lastRow = currentRow + visibleRowIndexes.length;
    
        NSColor *highlightColor;
    
        //Determine color of selection bar based on key/main/first responder status.
        if (self == [[self window] firstResponder] && [[self window] isMainWindow] && [[self window] isKeyWindow]) {
            highlightColor = [NSColor colorWithDeviceRed:0.0 green:0.0 blue:0.3 alpha:1.0];
        } else
            highlightColor = [NSColor lightGrayColor];
        }
        [highlightColor setFill];
    
        //Get the Rect of only the name column. This is the only column that will be highlighted.
        //We'll intersect this rect with the row rect for the area to fill in.
        NSInteger nameColumn = [self columnWithIdentifier:@"name"];
        NSRect nameColumnRect = [self rectOfColumn:nameColumn];
    
        while (currentRow < lastRow) {
            if ([selectedRowIndexes containsIndex:currentRow]) {
                NSRect drawRect = NSIntersectionRect([self rectOfRow:currentRow], nameColumnRect);
                NSRectFill(drawRect);
            }
            currentRow++;
        }
    }
    

    It’s important to note that I had to override my custom NSCell subclass’s drawInteriorWithFrame:inView: method to keep it from drawing the standard highlight, like this:

    -(void) drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
    {
        //do drawing here...don't call super.
    }
    

    So there’s a solution for part of the question. If this isn’t the “correct” way, please let me know :).

    CLICKING/DRAGGING IN VIS/LOCK COLUMNS SHOULD NOT CHANGE THE SELECTION
    I’ve determined now that I should be doing this in the

    -(NSIndexSet *) outlineView:(NSOutlineView *)outlineView selectionIndexesForProposedSelection:(NSIndexSet *)proposedSelectionIndexes
    

    method. If I’m in the middle of a drag that originated in the visibility or lock columns, I just return the current selectedRows to keep the selection the same. I haven’t implemented this yet, but it should be easy once I get my final problem solved (see below).

    DRAGGING UP OR DOWN IN VISIBILITY/LOCKED COLUMNS TO CHANGE THEIR STATE

    I’m getting really close with this one. In my custom NSCell, I’ve overridden the following three methods:

    -(BOOL) startTrackingAt:(NSPoint)startPoint inView:(NSView *)controlView
    -(BOOL) continueTracking:(NSPoint)lastPoint at:(NSPoint)currentPoint inView:(NSView *)controlView
    -(void) stopTracking:(NSPoint) lastPoint at:(NSPoint)stopPoint inView:(NSView *)controlView mouseIsUp:(BOOL)flag
    

    I’m down to my last problem, and here it is: I need to know when I’m inside the dragging operation and when the dragging operation finishes. There’s two ways I can do this:

    If I do not override

    +(BOOL) prefersTrackingUntilMouseUp
    

    in my NSCell subclass (so it returns the default NO value), then I receive a stopTracking:at:inView:mouseIsUp: message every time I leave a cell and go to the next one during a dragging operation…which means I can’t use that method to determine when the dragging operation is done.

    If instead I do override

    +(BOOL) prefersTrackingUntilMouseUp
    

    and return YES, I get a stopTracking:… call only on mouse up, which is great…but the problem is that the table doesn’t seem to update the UI for the cell on mouseDown or while I’m dragging inside the cell. For instance, in the startTracking:… method, if I set the cell’s objectValue to nil (so that its image is no longer displayed), I don’t see the update until the mouse button goes back up or the cursor leaves the cell. (When prefersTrackingUntilMouseUp returned NO, it updated immediately).

    So I need to both be able to update the cell’s UI immediately (on mouseDown) but also have a way to know when the dragging operation completes. This is the final piece of the puzzle. Can anyone help?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question about implementing the new UI within a .net website that
So I have a few questions about implementing the Android action bar. Up to
I have a question about implementing WYSIWYG editors into CakePHP. I'm developing an intranet
I have a question about interface and class implementing interface. This is my code:
I'm new to the play framework and I have a question about implementing ajax.
I have question about parsing in Html helper : I have sth like: @foreach
I have question about clean thory in Python. When: @decorator_func def func(bla, alba): pass
I have question about XSLT1.0. The task is to write out in HTML all
I have question about normalization. Suppose I have an applications dealing with songs. First
I have question about interpreting strings as packed binary data in C++. In python,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.