Re: NSMatrix of text fields
Re: NSMatrix of text fields
- Subject: Re: NSMatrix of text fields
- From: Andrew Merenbach <email@hidden>
- Date: Wed, 8 Oct 2008 15:34:06 -0700
On Oct 8, 2008, at 11:58 AM, DKJ wrote:
On 8 Oct, 2008, at 11:40, Andy Lee wrote:
I don't know offhand, but out of curiosity, what does it mean to
have a matrix of text fields in radio mode? Which cell would be
the selected cell?
--Andy
All I really want is for the matrix to detect which of the 64 text
fields has been clicked. I could just use buttons, but I want to
have different background colours, and I didn't see any easy way to
do that with buttons.
I'm sure there's a straightforward solution. But I am curious about
why it worked in List mode, but none of the others.
Hi!
My suggestion would be to make a subclass of NSButtonCell. I've done
this in a program of mine for a periodic table of the elements, and it
looks lovely. For your button cell's -drawInteriorWithFrame:, try
something like the following. You will likely want an alpha component
so that the button still looks like a button and not like a solid
square of color (unless that's what you want).
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView
*)controlView {
[super drawInteriorWithFrame:cellFrame inView:controlView];
CGFloat theAlpha = 0.25;
NSColor *color = [[self myBackgroundColor]
colorWithAlphaComponent:theAlpha];
[color set];
NSRectFillUsingOperation(cellFrame, NSCompositeSourceOver);
}
Of course, you may want a custom border for your cell, which would
require you to call something like
NSFrameRectWithWidthUsingOperation(). Also, you may wish to modify
the alpha variable (theAlpha) depending upon whether the cell is
selected. You'll need to implement a -myBackgroundColor (or whatever
you wish to call it) in order to return the correct color (however it
is that you plan to determine it).
If you'd like any further assistance with this code, let me know off-
list.
Cheers,
Andrew
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden