Skip to content

Commit c3d5333

Browse files
committed
Correct argument order for function. Now working, no further changes
1 parent c87478f commit c3d5333

File tree

2 files changed

+40
-31
lines changed

2 files changed

+40
-31
lines changed

Headers/AppKit/NSPanel.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ APPKIT_EXPORT NSInteger NSRunAlertPanel(NSString *title,
125125

126126
// Synchronous alert that is displayed as a sheet attached to the provided
127127
// window. If docWindow is nil it falls back to NSRunAlertPanel.
128-
APPKIT_EXPORT NSInteger NSRunAlertPanelRelativeToWindow(NSWindow *docWindow,
129-
NSString *title,
128+
APPKIT_EXPORT NSInteger NSRunAlertPanelRelativeToWindow(NSString *title,
130129
NSString *msg,
131130
NSString *defaultButton,
132131
NSString *alternateButton,
133-
NSString *otherButton, ...);
132+
NSString *otherButton,
133+
NSWindow *docWindow, ...);
134134

135135
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
136136
APPKIT_EXPORT NSInteger NSRunCriticalAlertPanel(NSString *title,

Source/NSAlert.m

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,46 +1774,55 @@ void NSBeginInformationalAlertSheet(NSString *title,
17741774
// NSRunAlertPanel which shows a modal alert. Otherwise display a sheet
17751775
// attached to docWindow and run a modal loop until it completes.
17761776
NSInteger
1777-
NSRunAlertPanelRelativeToWindow(NSWindow *docWindow,
1778-
NSString *title,
1779-
NSString *msg,
1780-
NSString *defaultButton,
1781-
NSString *alternateButton,
1782-
NSString *otherButton, ...)
1777+
NSRunAlertPanelRelativeToWindow(NSString *title,
1778+
NSString *msg,
1779+
NSString *defaultButton,
1780+
NSString *alternateButton,
1781+
NSString *otherButton,
1782+
NSWindow *docWindow, ...)
17831783
{
17841784
va_list ap;
1785-
NSString *message;
1786-
GSAlertPanel *panel;
1787-
NSInteger result;
1785+
NSString *message = nil;
1786+
GSAlertPanel *panel = nil;
1787+
NSInteger result = 0;
17881788

1789-
va_start(ap, otherButton);
1789+
va_start(ap, docWindow);
17901790
message = [NSString stringWithFormat: msg arguments: ap];
17911791
va_end(ap);
17921792

1793+
// Set the default button...
1794+
if (defaultButton == nil)
1795+
{
1796+
defaultButton = @"OK";
1797+
}
1798+
1799+
// Show a panel or a sheet depending on if we have a window...
17931800
if (docWindow == nil)
17941801
{
1795-
if (defaultButton == nil)
1796-
defaultButton = @"OK";
1797-
panel = getSomePanel(&standardAlertPanel, defaultTitle, title, message,
1802+
panel = getSomePanel(&standardAlertPanel,
1803+
defaultTitle,
1804+
title,
1805+
message,
17981806
defaultButton, alternateButton, otherButton);
1807+
17991808
result = [panel runModal];
1800-
NSReleaseAlertPanel(panel);
1801-
return result;
18021809
}
1810+
else
1811+
{
1812+
panel = getSomeSheet(&standardAlertPanel,
1813+
defaultTitle,
1814+
title,
1815+
message,
1816+
defaultButton, alternateButton, otherButton);
18031817

1804-
if (defaultButton == nil)
1805-
defaultButton = @"OK";
1806-
1807-
panel = getSomeSheet(&standardAlertPanel, defaultTitle, title, message,
1808-
defaultButton, alternateButton, otherButton);
1809-
1810-
[panel makeKeyAndOrderFront: nil];
1811-
[NSApp beginSheet: panel
1812-
modalForWindow: docWindow
1813-
modalDelegate: nil
1814-
didEndSelector: NULL
1815-
contextInfo: NULL];
1816-
result = [panel result];
1818+
[NSApp beginSheet: panel
1819+
modalForWindow: docWindow
1820+
modalDelegate: nil
1821+
didEndSelector: NULL
1822+
contextInfo: NULL];
1823+
1824+
result = [panel result];
1825+
}
18171826

18181827
NSReleaseAlertPanel(panel);
18191828
return result;

0 commit comments

Comments
 (0)