[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] NSSavePanel.m -beginSheetForDirectory::::::
From: |
Kazunobu Kuriyama |
Subject: |
[PATCH] NSSavePanel.m -beginSheetForDirectory:::::: |
Date: |
Sun, 29 Feb 2004 00:17:32 +0900 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; ja-JP; rv:1.4) Gecko/20030624 Netscape/7.1 |
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.
- Kazunobu Kuriyama
2004-02-28 Kazunobu Kuriyama <kazunobu.kuriyama@nifty.com>
* Source/NSSavePanel.m: (-beginSheetForDirectory::::::)
Reimplemented so that didEndSelector will be invoked with either
NSCancelButton or NSOKButton as its second argument.
Index: NSSavePanel.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/NSSavePanel.m,v
retrieving revision 1.77
diff -u -r1.77 NSSavePanel.m
--- NSSavePanel.m 28 Oct 2003 20:27:54 -0000 1.77
+++ NSSavePanel.m 28 Feb 2004 13:42:07 -0000
@@ -920,12 +920,20 @@
didEndSelector: (SEL)didEndSelector
contextInfo: (void *)contextInfo
{
- [self _setupForDirectory: path file: filename];
- [NSApp beginSheet: self
- modalForWindow: docWindow
- modalDelegate: delegate
- didEndSelector: didEndSelector
- contextInfo: contextInfo];
+ int ret;
+ void (*didEnd)(id, SEL, id, int, void *);
+
+ ret = [self runModalForDirectory: path
+ file: filename
+ relativeToWindow: docWindow];
+
+ if (delegate && [delegate respondsToSelector: didEndSelector])
+ {
+ didEnd = (void (*)(id, SEL, id, int, void *))
+ [delegate methodForSelector: didEndSelector];
+
+ (*didEnd)(delegate, didEndSelector, self, ret, contextInfo);
+ }
}
/**
- [PATCH] NSSavePanel.m -beginSheetForDirectory::::::,
Kazunobu Kuriyama <=