summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2025-11-27 21:28:08 +0200
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2025-11-28 11:16:05 +0200
commitbae1e1053de5db189b729f7c40e77fa26fe83766 (patch)
tree730841291de39c6244a3747cb506299e79d71cc9 /indra
parent449a5a1467390297d568720a87de2851589bef15 (diff)
#4322 Upload>Model button is sometimes disabled on MacOS
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llfilepicker_mac.h3
-rw-r--r--indra/newview/llfilepicker_mac.mm75
2 files changed, 58 insertions, 20 deletions
diff --git a/indra/newview/llfilepicker_mac.h b/indra/newview/llfilepicker_mac.h
index 77cc8540bc..f0e9ce81dc 100644
--- a/indra/newview/llfilepicker_mac.h
+++ b/indra/newview/llfilepicker_mac.h
@@ -42,6 +42,9 @@
std::unique_ptr<std::vector<std::string>> doLoadDialog(const std::vector<std::string>* allowed_types,
unsigned int flags);
+// doLoadDialogModeless if window does not exists creates a modeless
+// window, if it does exist, creates a 'sheet' that does not block
+// thead but blocks window interractions
void doLoadDialogModeless(const std::vector<std::string>* allowed_types,
unsigned int flags,
void (*callback)(bool, std::vector<std::string>&, void*),
diff --git a/indra/newview/llfilepicker_mac.mm b/indra/newview/llfilepicker_mac.mm
index 6cb7c4ad51..6921cd6101 100644
--- a/indra/newview/llfilepicker_mac.mm
+++ b/indra/newview/llfilepicker_mac.mm
@@ -114,38 +114,73 @@ void doLoadDialogModeless(const std::vector<std::string>* allowed_types,
@autoreleasepool
{
- // Note: might need to return and save this panel
- // so that it does not close immediately
NSOpenPanel *panel = init_panel(allowed_types,flags);
+ NSWindow *mainWindow = [NSApp mainWindow];
- [panel beginWithCompletionHandler:^(NSModalResponse result)
+ if (mainWindow)
{
- std::vector<std::string> outfiles;
- if (result == NSModalResponseOK)
+ [panel beginSheetModalForWindow:mainWindow
+ completionHandler:^(NSModalResponse result)
{
- NSArray *filesToOpen = [panel URLs];
- int i, count = [filesToOpen count];
-
- if (count > 0)
+ std::vector<std::string> outfiles;
+ if (result == NSModalResponseOK)
{
+ NSArray *filesToOpen = [panel URLs];
+ int i, count = [filesToOpen count];
- for (i=0; i<count; i++) {
- NSString *aFile = [[filesToOpen objectAtIndex:i] path];
- std::string *afilestr = new std::string([aFile UTF8String]);
- outfiles.push_back(*afilestr);
+ if (count > 0)
+ {
+
+ for (i=0; i<count; i++) {
+ NSString *aFile = [[filesToOpen objectAtIndex:i] path];
+ std::string *afilestr = new std::string([aFile UTF8String]);
+ outfiles.push_back(*afilestr);
+ }
+ callback(true, outfiles, userdata);
+ }
+ else // no valid result
+ {
+ callback(false, outfiles, userdata);
}
- callback(true, outfiles, userdata);
}
- else // no valid result
+ else // cancel
{
callback(false, outfiles, userdata);
}
- }
- else // cancel
+ }];
+ }
+ else
+ {
+ //present as modeless window
+ [panel beginWithCompletionHandler:^(NSModalResponse result)
{
- callback(false, outfiles, userdata);
- }
- }];
+ std::vector<std::string> outfiles;
+ if (result == NSModalResponseOK)
+ {
+ NSArray *filesToOpen = [panel URLs];
+ int i, count = [filesToOpen count];
+
+ if (count > 0)
+ {
+
+ for (i=0; i<count; i++) {
+ NSString *aFile = [[filesToOpen objectAtIndex:i] path];
+ std::string *afilestr = new std::string([aFile UTF8String]);
+ outfiles.push_back(*afilestr);
+ }
+ callback(true, outfiles, userdata);
+ }
+ else // no valid result
+ {
+ callback(false, outfiles, userdata);
+ }
+ }
+ else // cancel
+ {
+ callback(false, outfiles, userdata);
+ }
+ }];
+ }
}
}