mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 18:11:56 +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
fcbb8144be
commit
4b6d5a490a
2 changed files with 23 additions and 6 deletions
|
@ -66,6 +66,8 @@ enum {
|
||||||
id _delegate;
|
id _delegate;
|
||||||
NSAlertStyle _style;
|
NSAlertStyle _style;
|
||||||
BOOL _shows_help;
|
BOOL _shows_help;
|
||||||
|
id _modalDelegate;
|
||||||
|
SEL _didEndSelector;
|
||||||
int _result;
|
int _result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1510,11 +1510,11 @@ void NSBeginInformationalAlertSheet(NSString *title,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[button setTag: NSAlertFirstButtonReturn + count];
|
[button setTag: NSAlertFirstButtonReturn + count];
|
||||||
if ([aTitle isEqualToString: @"Cancel"])
|
if ([aTitle isEqualToString: _(@"Cancel")])
|
||||||
{
|
{
|
||||||
[button setKeyEquivalent: @"\e"];
|
[button setKeyEquivalent: @"\e"];
|
||||||
}
|
}
|
||||||
else if ([aTitle isEqualToString: @"Don't Save"])
|
else if ([aTitle isEqualToString: _(@"Don't Save")])
|
||||||
{
|
{
|
||||||
[button setKeyEquivalent: @"D"];
|
[button setKeyEquivalent: @"D"];
|
||||||
[button setKeyEquivalentModifierMask: NSCommandKeyMask];
|
[button setKeyEquivalentModifierMask: NSCommandKeyMask];
|
||||||
|
@ -1603,8 +1603,8 @@ void NSBeginInformationalAlertSheet(NSString *title,
|
||||||
}
|
}
|
||||||
[panel setTitleBar: title
|
[panel setTitleBar: title
|
||||||
icon: _icon
|
icon: _icon
|
||||||
title: _informative_text
|
title: _message_text != nil ? _message_text : _(@"Alert")
|
||||||
message: _message_text
|
message: _informative_text
|
||||||
def: (nbut > 0) ? [[_buttons objectAtIndex: 0] title] : (NSString*)nil
|
def: (nbut > 0) ? [[_buttons objectAtIndex: 0] title] : (NSString*)nil
|
||||||
alt: (nbut > 1) ? [[_buttons objectAtIndex: 1] title] : (NSString*)nil
|
alt: (nbut > 1) ? [[_buttons objectAtIndex: 1] title] : (NSString*)nil
|
||||||
other: (nbut > 2) ? [[_buttons objectAtIndex: 2] title] : (NSString*)nil];
|
other: (nbut > 2) ? [[_buttons objectAtIndex: 2] title] : (NSString*)nil];
|
||||||
|
@ -1645,15 +1645,30 @@ void NSBeginInformationalAlertSheet(NSString *title,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
_modalDelegate = delegate;
|
||||||
|
_didEndSelector = didEndSelector;
|
||||||
[NSApp beginSheet: _window
|
[NSApp beginSheet: _window
|
||||||
modalForWindow: window
|
modalForWindow: window
|
||||||
modalDelegate: delegate
|
modalDelegate: self
|
||||||
didEndSelector: didEndSelector
|
didEndSelector: @selector(_alertDidEnd:returnCode:contextInfo:)
|
||||||
contextInfo: contextInfo];
|
contextInfo: contextInfo];
|
||||||
DESTROY(_window);
|
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
|
- (id) window
|
||||||
{
|
{
|
||||||
return _window;
|
return _window;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue