views:

25

answers:

1

I'm creating an application which should show a progress bar in the dock icon. Currently I have this, but it's not working:

  NSProgressIndicator *progressIndicator = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0.0f, 0.0f, 10.0f, 20.0f)];
  [progressIndicator setStyle:NSProgressIndicatorBarStyle];
  [progressIndicator setIndeterminate:NO];
  [[[[NSApplication sharedApplication] dockTile] contentView] addSubview:progressIndicator];
  [progressIndicator release];

Or must I draw it on the dock myself? Can anyone help me? Thanks.

A: 

Just had a play around with the DockTile sample code: http://developer.apple.com/library/mac/#samplecode/DockTile/Introduction/Intro.html#//apple_ref/doc/uid/DTS10004391

I managed to get an NSProgress bar to display there by adding

NSProgressIndicator *progressIndicator = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0.0f, 0.0f, 100.0f, 20.0f)];
[self addSubview:progressIndicator];
[progressIndicator setStyle:NSProgressIndicatorBarStyle];
[progressIndicator setIndeterminate:NO];
[progressIndicator setMinValue:0];
[progressIndicator setMaxValue:100];
[progressIndicator setDoubleValue:25];
[progressIndicator release];

to SpeedometerView.m in initWithFrame, but it was still greyed out in the dock.

I also found this page: http://osx.hyperjeff.net/Apps/apps?p=4&sub=22&l=1&u=on which has "PMProgressIndicator" which might help, but I didn't dive through it.

Hope that helps a bit, post back on here if you figure it out, I'd be interested to know as well.

Oliver
I figured out that I need to redisplay the docktile's view every time the progress bar has changed. (:
Time Machine
Was the bar greyed out for you? When I had a quick go, it was always greyed out for me...
Oliver