Re: [Newbie] Displaying an NSImage inside an NSTextField?
Re: [Newbie] Displaying an NSImage inside an NSTextField?
- Subject: Re: [Newbie] Displaying an NSImage inside an NSTextField?
- From: WT <email@hidden>
- Date: Tue, 30 Jun 2009 15:23:49 +0200
On Jun 30, 2009, at 2:51 PM, email@hidden wrote:
Hello *,
I am currently trying to write a program that does the following:
- Has a bunch of questions/answers stored internally
- displays a random question in one area of the GUI and hides the
answer to that question in another area of the GUI
- displays the answer when you click "show answer"
So yeah it's supposed to be a rather simple "study tool".
My question/problem is:
I initially thought that I could just have two NSTextFields, one for
the question, one for the answer, however the problem with that is
that some of the questions and answers actually include little
images and I've been struggling for the past days trying to find out
if, and if 'how', I can display an NSImage *inside* an NSTextField.
But maybe this approach is totally newbish and crude and there is a
much more elegant and cocoa-ish solution for what I'm trying to
achieve?
I hope someone can help me with an answer or a good pointer to the
answer of my problem.
Thanks much in advance!!
-Philipp
Hi Philipp,
you could have the image be shown (when needed) in an NSImageView that
is placed next to the answer (which is a NSTextField), so you could
have something like this:
<text field for the question>.......................<image
view>...<text field for the answer>
(or some other arrangement of the three views). When you want to show
an answer, you'd update the answer field and, if it's the case that it
has an associated image, you'd also update the image view and then
make it visible. When there's no image associated with the answer,
you'd just hide the image view.
That's much easier (and flexible) than trying to make an image appear
inside the text field.
Wagner
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden