Re: Programmatically creating NSButton
Re: Programmatically creating NSButton
- Subject: Re: Programmatically creating NSButton
- From: Jeremy Dronfield <email@hidden>
- Date: Sat, 24 Apr 2004 15:27:12 +0100
I'm not quite clear now exactly what your goal is. Are you trying to
make a button from a custom image, or are you simply trying to create
and display a standard NSButton programmatically? It sounded originally
like you wanted the latter, but now I'm not so sure.
-Jeremy
On 24 Apr 2004, at 2:35 pm, Greg Hulands wrote:
What I have now done is created a prototype button in IB and made
connections through to them so I can access the cell and the exact same
thing is happening when using the cell of a "properly created" button.
For instance, the text is not vertically aligned like it should be
(center) and the key equivalent is not shown, in this case the button
should be blue for "\r".
This is really quite puzzling as there seems to be something not
happening when just drawing the cell.
Here is the code that captures the button cell into an image.
- (NSImage *)btnGenerator:(NSButtonCell *)btn
{
NSSize size = [btn cellSize];
size.width += 2 * [padding floatValue];
NSImage *img = [[NSImage alloc] initWithSize:size];
NSRect frame = NSMakeRect(0,0,size.width, size.height);
[img lockFocus];
[[NSColor clearColor] set];
NSRectFill(frame);
[btn drawWithFrame:frame
inView:nil];
[img unlockFocus];
return [img autorelease];
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.