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 8617235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:48:27+00:00 2026-06-12T05:48:27+00:00

I have NSStatusItem with a custom NSView which shows images. Whether the menu is

  • 0

I have NSStatusItem with a custom NSView which shows images.
Whether the menu is opened or not it show different images just like that:

 isMenuVisible = NO;

- (void)awakeFromNib {

statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
[statusItem retain];

dragStatusView = [[DragStatusView alloc] init];
[dragStatusView retain];
dragStatusView.statusItem = statusItem;
[dragStatusView setMenu:statusMenu];
[dragStatusView setToolTip:NSLocalizedString(@"Menubar Countdown",
                                             @"Status Item Tooltip")];
[statusItem setView:dragStatusView];
[dragStatusView setTitle:@"11"];
}

- (void)drawImage:(NSImage *)aImage centeredInRect:(NSRect)aRect{
NSRect imageRect = NSMakeRect((CGFloat)round(aRect.size.width*0.5f-aImage.size.width*0.5f),
                              (CGFloat)round(aRect.size.height*0.5f-aImage.size.height*0.5f),
                              aImage.size.width, 
                              aImage.size.height);
[aImage drawInRect:imageRect fromRect:NSZeroRect operation:NSCompositeSourceOver  fraction:1.0f];
}

- (void)drawRect:(NSRect)rect {
// Draw status bar background, highlighted if menu is showing
[statusItem drawStatusBarBackgroundInRect:[self bounds]
                            withHighlight:isMenuVisible];




if(isMenuVisible) {
    [self drawImage:image2 centeredInRect:rect];
}else {
    [self drawImage:image1 centeredInRect:rect];

}}

(Of course this is not everything, but i hope all the relevant code to understand my problem)

Now i want to show a NSProgressIndicator in this NSView (in this NSStatusItem) if an upload is proceeding which means
1. Set the NSProgressIndicator when upload starts
2.Received something ? ==> Hide NSProgressIndicator show the image again.

How would i solve this ?

Please help me. Thanks

  • 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-12T05:48:28+00:00Added an answer on June 12, 2026 at 5:48 am

    Here is the solution for View based status item.

    NSStatusBar *bar = [NSStatusBar systemStatusBar];
    self.theItem = [bar statusItemWithLength:NSVariableStatusItemLength];
    self.statusView = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 40, 20)];
    NSProgressIndicator* progress = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0, 0, 40, 20)];
    [progress setIndeterminate:NO];
    [self.statusView addSubview:progress];
    self.theItem.view = self.statusView;
    

    You can also draw a progress bar your self in Menu based status item
    on progress change you can simply change the image of your status item.

    - (void) updateIconWithProgress:(float)aProgress
    {
        NSImage* image = [NSImage imageNamed:@"small_icon_16_16.png"];
        NSImage* img = [image copy];
        [img lockFocus];
    
        NSRect rect = NSMakeRect(2, 4, 12.0*aProgress, 8.0);
        [[NSColor blueColor] set];
        [NSBezierPath fillRect:rect];
    
        [img unlockFocus];
        [self.theItem setImage:img];
    }
    

    p.s. The code was written for ARC (Automatic Reference Counting) so there is no retain or release.

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

Sidebar

Related Questions

I have an NSStatusItem that has an NSMenuItem which contains a custom NSView. this
Currently, I have an NSStatusItem that, when clicked, shows a custom view below it.
I have a variable length NSStatusItem which I'd like to stay visible whenever possible,
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
I have a custom view in an NSStatusItem object. This view displays icons. It's
I have an application that is an NSStatusItem . It has a few different
I have an NSStatusItem that displays an NSMenu full of NSView subclasses. I override
I have a Mac application, an NSStatusItem really, in which I'm trying to test
I have a simple app that has a NSStatusItem, which only displays an icon.
I have an NSMenu which opens when a user clicks an NSStatusItem in the

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.