Alert box support!

master
Geenz 2013-07-11 21:31:17 -04:00
parent 3a8ad62d9b
commit a787e272c3
4 changed files with 38 additions and 23 deletions

View File

@ -668,7 +668,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (BOOL) resignFirstResponder
{
callFocus();
callFocusLost();
return true;
}

View File

@ -69,6 +69,7 @@ void hideNSCursor();
void showNSCursor();
void hideNSCursorTillMove(bool hide);
void requestUserAttention();
long showAlert(std::string title, std::string text, int type);
NSWindowRef createNSWindow(int x, int y, int width, int height);

View File

@ -395,6 +395,41 @@ void requestUserAttention()
[[NSApplication sharedApplication] requestUserAttention:NSInformationalRequest];
}
long showAlert(std::string text, std::string title, int type)
{
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:[NSString stringWithCString:title.c_str() encoding:[NSString defaultCStringEncoding]]];
[alert setInformativeText:[NSString stringWithCString:text.c_str() encoding:[NSString defaultCStringEncoding]]];
if (type == 0)
{
[alert addButtonWithTitle:@"Okay"];
} else if (type == 1)
{
[alert addButtonWithTitle:@"Okay"];
[alert addButtonWithTitle:@"Cancel"];
} else if (type == 2)
{
[alert addButtonWithTitle:@"Yes"];
[alert addButtonWithTitle:@"No"];
}
long ret = [alert runModal];
[alert dealloc];
if (ret == NSAlertFirstButtonReturn)
{
ret = 0;
} else if (ret == NSAlertSecondButtonReturn)
{
ret = 1;
} else if (ret == NSAlertThirdButtonReturn)
{
ret = 2;
}
return ret;
}
/*
GLViewRef getGLView()
{

View File

@ -1597,24 +1597,6 @@ LLSplashScreenMacOSX::~LLSplashScreenMacOSX()
void LLSplashScreenMacOSX::showImpl()
{
// This code _could_ be used to display a spash screen...
#if 0
IBNibRef nib = NULL;
S32 err;
err = CreateNibReference(CFSTR("SecondLife"), &nib);
if(err == noErr)
{
CreateWindowFromNib(nib, CFSTR("Splash Screen"), &mWindow);
DisposeNibReference(nib);
}
if(mWindow != NULL)
{
ShowWindow(mWindow);
}
#endif
}
void LLSplashScreenMacOSX::updateImpl(const std::string& mesg)
@ -1636,12 +1618,9 @@ void LLSplashScreenMacOSX::hideImpl()
}
}
S32 OSMessageBoxMacOSX(const std::string& text, const std::string& caption, U32 type)
{
// TODO: Implement a native NSAlert function that replicates all of this.
return 0;
return showAlert(text, caption, type);
}
// Open a URL with the user's default web browser.