Hi,
I have a problem when printing or exporting to pdf a view :
Suppose you have a window containing just a view, let's say a myView which inherits of course from NSView.
Suppose the drawRect: method is this :
Then you get a simple window which, when you select Print from the Edit menu and Preview will give you a representation of your window, with the window border and title (and weird titlebar corners in my experience), and the view inside it.
So far so good...
Suppose you now add this to the myView method :
then the Print command won't print the border of your window, nor its title, but only the content of the view inside the window which sounds reasonable enough.
But, it appears that although the text is still there, precisely where it should be, you have too look hard to see it, as it appears in a microscopic size... The lines, rect or whatever objects you drew on the view do appear in the same size as previously...
I tested on my macbook (10.4.11, xcode 2.4) and mac pro (10.5.2, xcode 3.0), both exhibited the same behavior...
As usual, I wonder... Am I doing something wrong ? and whatever the answer to this first question, how do I fix this ?
phjo
I have a problem when printing or exporting to pdf a view :
Suppose you have a window containing just a view, let's say a myView which inherits of course from NSView.
Suppose the drawRect: method is this :
Code:
- (void)drawRect:(NSRect)rect {
CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
CGContextSetRGBFillColor(context,0,0,1,1);
CGContextSelectFont(context,"Helvetica",2,kCGEncodingMacRoman);
CGContextShowTextAtPoint(context,20,20,"test",4);
CGContextBeginPath(context);
CGContextMoveToPoint(context, 20,18);
CGContextAddLineToPoint(context, 65,18);
CGContextStrokePath(context);
CGContextFlush(context);
}
Then you get a simple window which, when you select Print from the Edit menu and Preview will give you a representation of your window, with the window border and title (and weird titlebar corners in my experience), and the view inside it.
So far so good...
Suppose you now add this to the myView method :
Code:
-(BOOL)acceptsFirstResponder
{
return YES;
}
then the Print command won't print the border of your window, nor its title, but only the content of the view inside the window which sounds reasonable enough.
But, it appears that although the text is still there, precisely where it should be, you have too look hard to see it, as it appears in a microscopic size... The lines, rect or whatever objects you drew on the view do appear in the same size as previously...
I tested on my macbook (10.4.11, xcode 2.4) and mac pro (10.5.2, xcode 3.0), both exhibited the same behavior...
As usual, I wonder... Am I doing something wrong ? and whatever the answer to this first question, how do I fix this ?
phjo