bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] NSSavePanel.m -beginSheetForDirectory::::::


From: Fred Kiefer
Subject: Re: [PATCH] NSSavePanel.m -beginSheetForDirectory::::::
Date: Sat, 28 Feb 2004 17:59:03 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030821

Kazunobu Kuriyama wrote:
> Attached is a patch that corrects NSSavePanel's
> 
> - (void)beginSheetForDirectory: (NSString *)path
> fileName: (NSString *)filename
> modalForWindow: (NSWindow *)docWindow
> modalDelegate: (id)delegate
> didEndSelector: (SEL)didEndSelector
> contextInfo: (void *)contextInfo;
> 
> For the case where delegate is non-nil, the current
> implementation fails to work when the OK button on
> the sheet is pressed.
> 
> (As delegate is set to nil mostly, this bug has
> seemingly been overlooked, IMHO.)
> 
> Reason: The current implementation directly invokes
> NSApplication's -beginSheet::::: through the global
> NSApp. In the implementation of this method, we see
> 
> ret = [self runModalForWindow: arg1
> relativeToWindow: arg2];
> 
> and ret is passed to didEndSelector. Since self is
> NSApp, -runModalForWindow:relativeToWindow: invoked
> in this case is the one implemented in NSApplication.
> However, that method returns neither NSCancelButton nor
> NSOKButton, which are to be passed to didEndSelector by
> the specifications when NSSavePanel or NSOpenPanel is used.
> 
> Rather, when using NSSavePanel or NSOpenPanel, ret is always
> set to NSRunStoppedResponse (0), which is incidentally equal
> to NSCancelButton (0). This is why the sheet fails to work
> when the OK button is pressed.
> 
> The patch rectifies the NSSavePanel's method so that it
> can work with the OK button properly.
> 
> Recently, someone corrected the signature of didEndSelector
> found in NSApplication.m, the need of which was pointed out
> by my previous patch. The attached patch relies on that
> correction. So use the latest CVS if you would like to
> try it.
> 

This patch tries to add another workaround on top of all the hacks, that
are already there for model and sheet handling. This doesn't look right
to me, so I suggest another, hopefully cleaner, way to resolve this:

We should give the correct Cocoa values to the constants
NSRunStoppedResponse, NSRunAbortedResponse and  NSRunContinuesResponse.
With these there will no longer be a conflict to the values of
NSCancelButton and NSOKButton. So we are able to undo the hack Nicola
put into the save panel years ago and to use stopModalWithCode: there
again, using the button constant as the code. That way everything will
fall into place again and no further hacks will be needed.
And perhaps somebody will in the future even donate a fully working
sheet processing to GNUstep.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]