Re: simple printing question
Re: simple printing question
- Subject: Re: simple printing question
- From: Tom Bernard <email@hidden>
- Date: Sun, 27 Jun 2004 18:40:30 -0600
You need to use initWithFrame: to initialize the NSTextView; init leaves the
view with a zero width and height frame.
NSTextView *view = [[NSTextView alloc]
initWithFrame:NSMakeRect(0,0,200,200)];
Regards,
Tom Bernard
email@hidden
on 6/26/04 10:20 AM, Peter Borg at email@hidden wrote:
>
insertText in a NSView (or rather what it inherits from NSResponder)
>
doesn't really do much but leaves it to the subclasses of NSView (like
>
NSTextView) to implement it, as one can see in the documentation:
>
"Overridden by subclasses to insert aString at the insertion point or
>
selection, deleting the selection if there is one. NSResponders
>
implementation simply passes this message to the next responder, or
>
beeps if there is no next responder."
>
>
So try your code with a NSTextView instead (and try perhaps setString:
>
instead of insertText:) which would leave you with code like this:
>
>
NSTextView *textView = [[NSTextView alloc] init];
>
[textView setString:[transToPrint descriptionSummary]];
>
op = [NSPrintOperation printOperationWithView:textView];
>
>
And remember to include a [textView release] at the end otherwise it
>
will leak.
>
>
Regards,
>
>
Peter
>
>
On 26 jun 2004, at 02.13, Andrew Kinnie wrote:
>
>
> Greetings,
>
>
>
> I am trying to print to a receipt printer in my app I'm developing.
>
> Basically, I am just trying to send the printer some text and have it
>
> print without dropping the print panel. I read the apple docs, and
>
> came up with this method from my controller method:
>
>
>
> - (void)printReceipt:(Transaction *)transToPrint
>
> {
>
> NSPrintOperation *op;
>
> NSView *view = [[NSView alloc] init];
>
> [view insertText:[transToPrint descriptionSummary]];
>
>
>
> op = [NSPrintOperation printOperationWithView:view];
>
>
>
> [op setShowPanels:NO];
>
> [op runOperation];
>
> }
>
>
>
> I run the app, run the method which calls this method, and I get a
>
> dialog "No pages in the document were selected to print."
_______________________________________________
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.