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

  • Home
  • SEARCH
  • 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 6067219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:35:05+00:00 2026-05-23T09:35:05+00:00

I have an NSOutlineView that uses a custom NSCell subclass to draw an NSProgressIndicator.

  • 0

I have an NSOutlineView that uses a custom NSCell subclass to draw an NSProgressIndicator. Each NSCell has a refreshing property that is set by the NSOutlineView delegate willDisplayCell:forItem: method, like so:

- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
    cell.refreshing = item.refreshing;
}

Each item instance contains an NSProgressIndicator that is started and stopped dependent upon whether that particular item is refreshing.

- (NSProgressIndicator *)startProgressIndicator
{
    if(!self.progressIndicator)
    {
        self.progressIndicator = [[[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0, 0, 16.0f, 16.0f)] autorelease];
        [self.progressIndicator setControlSize:NSSmallControlSize];
        [self.progressIndicator setStyle:NSProgressIndicatorSpinningStyle];
        [self.progressIndicator setDisplayedWhenStopped:YES];
        [self.progressIndicator setUsesThreadedAnimation:YES];
        [self.progressIndicator startAnimation:self];
    }

    return self.progressIndicator;
}
- (void)stopProgressIndicator
{
    if(self.progressIndicator != nil)
    {
        NSInteger row = [sourceList rowForItem:self];

        [self.progressIndicator setDisplayedWhenStopped:NO];
        [self.progressIndicator stopAnimation:self];
        [[self.progressIndicator superview] setNeedsDisplayInRect:[sourceList rectOfRow:row]];
        [self.progressIndicator removeFromSuperviewWithoutNeedingDisplay];

        self.progressIndicator = nil;
    }

    for(ProjectListItem *node in self.children)
    {
        [node stopProgressIndicator];
    }
}   

The items NSProgressIndicator instances are stopped and started within my NSCell’s drawInteriorWithFrame:inView: class, like so:

- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
    if(self.refreshing)
    {
        NSProgressIndicator *progressIndicator = [item progressIndicator];
        if (!progressIndicator)
        {
            progressIndicator = [item startProgressIndicator];
        }

        // Set the progress indicators frame here ...

        if ([progressIndicator superview] != controlView)
            [controlView addSubview:progressIndicator];

        if (!NSEqualRects([progressIndicator frame], progressIndicatorFrame)) {
            [progressIndicator setFrame:progressIndicatorFrame];
        }
    }
    else
    {
        [item stopProgressIndicator];
    }

    [super drawInteriorWithFrame:cellFrame inView:controlView];
}

The issue I’m having is that although the NSProgressIndicators are correctly told to stop, the calls to stopProgressIndicator have no effect. Here’s the code that fails to trigger the refresh of the NSOutlineView row in question. I’ve manually checked the NSRect returned by my call to rectOfRow and can confirm that the value is correct.

[self.progressIndicator setDisplayedWhenStopped:NO];
[self.progressIndicator stopAnimation:self];
[[self.progressIndicator superview] setNeedsDisplayInRect:[sourceList rectOfRow:row]];
[self.progressIndicator removeFromSuperviewWithoutNeedingDisplay];

self.progressIndicator = nil;

When the NSOutlineView finishes refreshing all of its items it triggers a reloadData: call. This is the only thing that seems to reliably update all of the cells in question, finally removing the NSProgressIndicators.

What am I doing wrong here?

  • 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-05-23T09:35:05+00:00Added an answer on May 23, 2026 at 9:35 am

    It’s bad practice to mess with view hierarchies while things are getting drawn. The best thing to do would be to use an NSCell version of NSProgressIndicator, but AppKit doesn’t have such a thing. The solution described in Daniel Jalkut’s answer to a similar question is probably the fastest path to what you want. Here’s the basic idea:

    Rather than use the refreshing variable to switch paths during drawing, observe your items’ refreshing state. When it becomes true, add an NSProgressIndicator as a subview of your NSOutlineView at the item’s position given frameOfCellAtColumn:row: (it can be convenient to set up a column for the progress indicators on the far right). When it becomes false, remove the corresponding progress indicator. You will also want to be sure to set the autosizing flags appropriately on these progress indicators so they move around as the outline view gets resized.

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

Sidebar

Related Questions

I have an NSOutlineView that I want to populate with a list of NSURL
I have an NSOutlineView and what I want to happen is that when a
In my app, I have an NSOutlineView that gets its data from a NSTreeController
I have an NSOutlineView with a custom NSOutlineViewDataSource based on the parent-child relationship or
I have a plist that is set up like: As you can see, I
The problem I have is that I have an NSOutlineView with Drag and Drop
I have a custom <NSOutlineViewDataSource> , for which I would its NSOutlineView to update
I have text fields inside a custom view inside an NSOutlineView . Editing one
I have a flawless functioning view-based NSOutlineView with a proper set-up datasource in my
I have an NSOutlineView with checkboxes. I have the checkbox state bound to a

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.