On Aug 25, 2014, at 3:06 PM, Daryle Walker <dary...@mac.com> wrote:

> When I print from the menu command, going through the action method, a text 
> document I have loaded in my WebView prints all its pages. When I did it 
> through the print-files Apple event, I only got 2 pages. And that was with 
> another file (but HTML) also in the direct parameter list; when I did the 
> text file by itself, I only got 1 page through. Suggestions?
> 
> (The print-doc Apple event shows no Print panel by default. If I can figure 
> out how to add the parameter to trigger the panel to the Apple event, I’ll 
> run it to see how many pages it thinks the document has, i.e. find out which 
> point in the process is dropping pages.)

“Plan to throw one away.”

That’s what I did; I started over. It seems to work now.

Both menu and Apple-event printing call to the same method. So I thought the 
problem is in the main difference, the NSPrintInfo object. I tried all sorts of 
combinations, including hard-coding the result from +sharedInfo, but the print 
jobs still came out screwy. 

My original class called -replyToOpenOrPrint: on the application object in the 
-main method. The main action occurs on notifications from my web-view’s 
window’s controller. The operation takes in the notifications and updates the 
statistics. (If printing, receipt of the finished-loading notification leads to 
calling the controller’s print method instead of flagging success.) The 
statistics are marked as key-path dependencies for the operation’s “isReady” 
property. So the subclass’ -isReady is built from the superclass version AND-ed 
with the download statistics.

When I put an NSOperation subclass instance into the main queue, is the task 
run on the main thread? Or just the scheduler? If the latter, that may have 
been my problem, running AppKit stuff on a non-main thread.

I made a similar class, not an NSOperation, whose state machine is a bunch of 
notification-listening to the web-loading process. Each notification checks if 
everything is done, and changes a Boolean flag if so.

These classes are stored in an NSMutableSet in the application delegate. When 
the open or print methods of the delegate are triggered, an instance of my new 
class is made and added to the set. The delegate also puts a KVO on the 
instance’s Boolean flag. Then the instance’s -start method is triggered from 
performSelector:withObject:delay: at the next run loop. When the instance 
changes its flag, the delegate gets the KVO notification and removes the 
instance from the set.

(To check if my new system had the correct pages, just change the 
“showPrintPanel” variable temporarily to a “YES” constant to see what it thinks 
it should send.)

— 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com 


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to