mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 15:11:37 +00:00
Pass correct arguments to the didEndSelector passed to NSAlert's
-beginSheetModalForWindow:delegate:didEndSelector:contextInfo: method. Fix swapping of title and informative message text in NSAlerts. Also supply a default title "Alert" if none is set. Determine key equivalent of NSAlert buttons from their localized titles. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27010 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
edd9b4a68a
commit
c1fd62315e
2 changed files with 23 additions and 6 deletions
|
@ -66,6 +66,8 @@ enum {
|
|||
id _delegate;
|
||||
NSAlertStyle _style;
|
||||
BOOL _shows_help;
|
||||
id _modalDelegate;
|
||||
SEL _didEndSelector;
|
||||
int _result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1510,11 +1510,11 @@ void NSBeginInformationalAlertSheet(NSString *title,
|
|||
else
|
||||
{
|
||||
[button setTag: NSAlertFirstButtonReturn + count];
|
||||
if ([aTitle isEqualToString: @"Cancel"])
|
||||
if ([aTitle isEqualToString: _(@"Cancel")])
|
||||
{
|
||||
[button setKeyEquivalent: @"\e"];
|
||||
}
|
||||
else if ([aTitle isEqualToString: @"Don't Save"])
|
||||
else if ([aTitle isEqualToString: _(@"Don't Save")])
|
||||
{
|
||||
[button setKeyEquivalent: @"D"];
|
||||
[button setKeyEquivalentModifierMask: NSCommandKeyMask];
|
||||
|
@ -1603,8 +1603,8 @@ void NSBeginInformationalAlertSheet(NSString *title,
|
|||
}
|
||||
[panel setTitleBar: title
|
||||
icon: _icon
|
||||
title: _informative_text
|
||||
message: _message_text
|
||||
title: _message_text != nil ? _message_text : _(@"Alert")
|
||||
message: _informative_text
|
||||
def: (nbut > 0) ? [[_buttons objectAtIndex: 0] title] : (NSString*)nil
|
||||
alt: (nbut > 1) ? [[_buttons objectAtIndex: 1] title] : (NSString*)nil
|
||||
other: (nbut > 2) ? [[_buttons objectAtIndex: 2] title] : (NSString*)nil];
|
||||
|
@ -1645,15 +1645,30 @@ void NSBeginInformationalAlertSheet(NSString *title,
|
|||
}
|
||||
else
|
||||
{
|
||||
_modalDelegate = delegate;
|
||||
_didEndSelector = didEndSelector;
|
||||
[NSApp beginSheet: _window
|
||||
modalForWindow: window
|
||||
modalDelegate: delegate
|
||||
didEndSelector: didEndSelector
|
||||
modalDelegate: self
|
||||
didEndSelector: @selector(_alertDidEnd:returnCode:contextInfo:)
|
||||
contextInfo: contextInfo];
|
||||
DESTROY(_window);
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _alertDidEnd: (NSWindow *)sheet
|
||||
returnCode: (int)returnCode
|
||||
contextInfo: (void *)contextInfo
|
||||
{
|
||||
if ([_modalDelegate respondsToSelector: _didEndSelector])
|
||||
{
|
||||
void (*didEnd)(id, SEL, id, int, void *);
|
||||
didEnd = (void (*)(id, SEL, id, int, void *))[_modalDelegate
|
||||
methodForSelector: _didEndSelector];
|
||||
didEnd(_modalDelegate, _didEndSelector, self, returnCode, contextInfo);
|
||||
}
|
||||
}
|
||||
|
||||
- (id) window
|
||||
{
|
||||
return _window;
|
||||
|
|
Loading…
Reference in a new issue