Re: Drawing text on top of a progress bar
Re: Drawing text on top of a progress bar
- Subject: Re: Drawing text on top of a progress bar
- From: Sherm Pendley <email@hidden>
- Date: Tue, 13 Jun 2006 23:55:34 -0400
On Jun 13, 2006, at 9:38 PM, Derrick Bass wrote:
I trying to create a custom view that displays text on top of a
progress bar (actually, displays a whole bunch of those next to one
another).
So in my init method, I allocate an NSProgressIndicator and an
NSTextField and I set the progress indicator to be a subview of my
custom view. I've read in the archives that overlapping views don't
work well, so I set the text field to be a subview of the progress
indicator. I've also set the text field's "setDrawsBackground" flag
to NO.
In my drawRect method, I setFrame the progress indicator and text
field and then I call drawRect for the progress indicator followed
by the text field. But whether the text or the progress bar comes
out on top seems arbitrary. Moreover, the text DOES draw the
background, so when it's on top it completely obscures the progress
bar below it.
I can only assume that I am going about this totally wrong, but I
have no idea how to fix it.
Have you tried subclassing NSProgressIndicator? You could override -
drawRect: to first call super's -drawRect:, which would take care of
the progress bar. Then you could use NSString's -
drawInRect:options:attributes: to draw your text over that.
sherm--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden