Cocoa printing/view issue

I’m trying to add printing capability to my RTAS plugin (OS X 10.5.x). I’ve started by loading a simple window from a nib that has a button that sends an action to my controller method which then tries to do Cocoa printing of the content view of that window. (I figure later on I will populate the view with the layout I want to print which will include images and text.) I tested the code in a separate app and it works, but not in the plugin. The problem happens when I call [NSPrintOperation runOperation] which seems to go into the wrong view. It ends up calling into JuceNSView’s drawRect method which leads me to think there may be a focus issue since I have a whole other window I’m trying to print, not the main plugin window.

I’m not using the latest git tip - it’s actually 1.46. I’ve seen other posts regarding focus issues. I’m wondering if this is something that might be fixed in the latest version of Juce or if there is a fix I can make on my version of Juce. Sorry I don’t have any code handy to post right now - hoping it’s clear enough from the description.

I don’t understand your point about focus issues… Surely if you get the NSView from the Component::getWindowHandle() method, the focus is irrelevant?

Hmmm, well bear with me as I am just learning Cocoa and ObjC for this purpose.

The window I’m popping up is not using Juce - it’s in a nib created with Interface Builder. The print button sends an action to a print controller class that creates the NSPrintOperation etc. I’m loading the nib after the user clicks something in the juce-based plugin window. When I go to print, I’m getting the content view of the new window which I have as an outlet or reference variable that I thought Cocoa is supposed to fill in for me when I load the nib. I pass that content view to NSPrintOperation before invoking runOperation. Somehow Cocoa is using the wrong window/view.

I have the same behavior as this dude, same call stack except for making its way into the juce code instead of mach_msg:

Someone from the cocoa-dev site calls it an OS bug that prevents cocoa printing from carbon apps.

Maybe I’ll try to do this using carbon.