Re: Intercept Save when closing NSDocument

2017-02-12 Thread Mike Abdullah

___

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


Re: Intercept Save when closing NSDocument

2017-02-11 Thread Uli Kusterer
On 10 Feb 2017, at 18:23, Jens Alfke  wrote:
> 
>> On Feb 10, 2017, at 9:19 AM, Keary Suska  wrote:
>> 
>> I would start by overriding -saveDocument: and -saveDocumentAs: in your 
>> NSDocument subclass with a breakpoint so I can see what is being done.
> 
> Even easier: wait for the save dialog to appear, then hit the Pause button in 
> the debugger and look at the backtrace to see the entire call chain. Look for 
> any NSDocument method that you can override.

 That was very handy for modal dialog panels. Sadly for modeless windows and 
modeless sheets, I don't think this still works. If anyone has a similar trick… 
I suppose you could try setting breakpoints in the various beginSheet calls in 
NSApplication/NSWindow, or maybe one on -setSheetParent: might be enough.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de


___

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

Re: Intercept Save when closing NSDocument

2017-02-10 Thread Kevin Perry
NSSavePanelDelegate is probably the approach you want to take, with 
-[NSDocument prepareSavePanel:] being the most convenient means of inserting 
your delegate.

> On Feb 10, 2017, at 9:41 AM, Quincey Morris 
>  wrote:
> 
> On Feb 10, 2017, at 08:12 , Trygve Inda  wrote:
>> 
>> I would like to disable the Save button
>> for a demo version of our app.
> 
> Have you looked at the NSSavePanelDelegate methods? One approach would be to 
> use panel:validateURL:error: to prevent the save proceeding. Another would be 
> to use (say) panelSelectionDidChange: to explicitly disable the Save button 
> (which has a documented view tag) if that works the the XPC environment of 
> the Save dialog.
> 
> ___
> 
> 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/kperry%40apple.com
> 
> This email sent to kpe...@apple.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


Re: Intercept Save when closing NSDocument

2017-02-10 Thread Quincey Morris
On Feb 10, 2017, at 08:12 , Trygve Inda  wrote:
> 
> I would like to disable the Save button
> for a demo version of our app.

Have you looked at the NSSavePanelDelegate methods? One approach would be to 
use panel:validateURL:error: to prevent the save proceeding. Another would be 
to use (say) panelSelectionDidChange: to explicitly disable the Save button 
(which has a documented view tag) if that works the the XPC environment of the 
Save dialog.

___

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


Re: Intercept Save when closing NSDocument

2017-02-10 Thread Trygve Inda
On 2/10/17, 9:19 AM, "Keary Suska"
 wrote:

>
>> On Feb 10, 2017, at 9:12 AM, Trygve Inda 
>>wrote:
>> 
>> When I close an NSDocument, it puts up a sheet offering (Don¹t Save,
>> Cancel, Save).
>> 
>> Is there a way to intercept this? I would like to disable the Save
>>button
>> for a demo version of our app. I could mark the document as having no
>> changes, but then it would just close directly and not allow a cancel
>> operation.
>> 
>> I can easily disable the menu Save/Save As but clicking the Save button
>>in
>> the close-sheet window jumps right into the file writing methods in my
>> NSDocument subclass.
>> 
>> Thanks for any ideas.
>
>I would start by overriding -saveDocument: and -saveDocumentAs: in your
>NSDocument subclass with a breakpoint so I can see what is being done. I
>might also start by subclassing
>-runModalSavePanelForSaveOperation:delegate:didSaveSelector:contextInfo:
>to see if that is the method used in these cases. Then there are also
>autosave issues if you intend to support autosave in your app...

Yup - I have overridden -saveDocument: and -saveDocumentAs:

They are called from the File-Save and File-Save As points, but not from
clicking Save in the “document is about to close” dialog. I am not
supporting Autosave as I am dealing with very large files.

Trygve





___

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

Re: Intercept Save when closing NSDocument

2017-02-10 Thread Jens Alfke

> On Feb 10, 2017, at 9:19 AM, Keary Suska  wrote:
> 
> I would start by overriding -saveDocument: and -saveDocumentAs: in your 
> NSDocument subclass with a breakpoint so I can see what is being done.

Even easier: wait for the save dialog to appear, then hit the Pause button in 
the debugger and look at the backtrace to see the entire call chain. Look for 
any NSDocument method that you can override.

—Jens

___

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

Re: Intercept Save when closing NSDocument

2017-02-10 Thread Keary Suska

> On Feb 10, 2017, at 9:12 AM, Trygve Inda  wrote:
> 
> When I close an NSDocument, it puts up a sheet offering (Don¹t Save,
> Cancel, Save).
> 
> Is there a way to intercept this? I would like to disable the Save button
> for a demo version of our app. I could mark the document as having no
> changes, but then it would just close directly and not allow a cancel
> operation.
> 
> I can easily disable the menu Save/Save As but clicking the Save button in
> the close-sheet window jumps right into the file writing methods in my
> NSDocument subclass.
> 
> Thanks for any ideas.

I would start by overriding -saveDocument: and -saveDocumentAs: in your 
NSDocument subclass with a breakpoint so I can see what is being done. I might 
also start by subclassing 
-runModalSavePanelForSaveOperation:delegate:didSaveSelector:contextInfo: to see 
if that is the method used in these cases. Then there are also autosave issues 
if you intend to support autosave in your app...

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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

Intercept Save when closing NSDocument

2017-02-10 Thread Trygve Inda
When I close an NSDocument, it puts up a sheet offering (Don¹t Save,
Cancel, Save).

Is there a way to intercept this? I would like to disable the Save button
for a demo version of our app. I could mark the document as having no
changes, but then it would just close directly and not allow a cancel
operation.

I can easily disable the menu Save/Save As but clicking the Save button in
the close-sheet window jumps right into the file writing methods in my
NSDocument subclass.

Thanks for any ideas.

Trygve




___

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