• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Text over graphics
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Text over graphics


  • Subject: Text over graphics
  • From: Angela Brett <email@hidden>
  • Date: Fri, 28 Sep 2001 19:54:44 +1200

Hi,

This is probably quite a simple thing to do, but I can't figure out how to do it. Basically I want to have some text over top of a bunch of composited images I've already drawn, and I want the text to be able to change.

I've tried doing this with NSTextFields and by drawing an NSString, but with both I get the same problem. If I don't specify a background colour (NSString) or setDrawsBackground:NO (NSTextField) then I can see the image behind it, which is what I want, but when the text changes the old text stays there underneath it. I would expect that to happen with drawing an NSString, but not really with an NSTextView.

If I setDrawsBackground:YES on the NSTextView, the old text doesn't stay around but the background of the text is a solid colour, I can't see the other stuff through it like I want to. That makes sense. So I thought I could get around that by setting the background colour of the NSTextField to [NSColor clearColor] - but that just gives it a black background. The NSTextView is a subView of the one with the composited images. I've got around this before by drawing the portion of the image each time before changing the text, but I can't do it in this case because the image behind the text is the result of quite a bit of compositing. Anyway, I'm pretty sure that's not the way it's supposed to be done, it seems sort of inefficient.

I can see two ways of getting what I want, and I don't know how to do either. I could use the NSString, and somehow clear the subView that it's on before drawing the new string. That seems like it really ought to be possible, but I don't know how to do it. The other way is to use the NSTextField, and somehow convince it that when the backgroundColor is clearColor, it's supposed to be clear and not black. In desperation I tried subclassing NSTextField so that isOpaque would return NO, but that didn't help. Hopefully someone can tell me how to do one of those things, or maybe tell me if there's a different way of doing it or a different kind of view to use.
--
Angela Brett email@hidden http://acronyms.co.nz/
"Yes, always keep the Classics at hand to prevent flop."
-- Virginia Woolf (anticipating Mac OS X?)


  • Follow-Ups:
    • Re: Text over graphics
      • From: "Erik M. Buck" <email@hidden>
    • Re: Text over graphics
      • From: "John C. Randolph" <email@hidden>
  • Prev by Date: Re: detecting
  • Next by Date: Re: NSTextViews and initial first responders
  • Previous by thread: Re: detecting
  • Next by thread: Re: Text over graphics
  • Index(es):
    • Date
    • Thread