mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Mac MessageBox: Fix result code conversion
This commit is contained in:
parent
eb8a419ac7
commit
0a34e7fa71
1 changed files with 19 additions and 11 deletions
|
|
@ -43,7 +43,15 @@ public:
|
|||
|
||||
int getResult() const
|
||||
{
|
||||
switch ([getAlert() runModal])
|
||||
return convertResult ([getAlert() runModal]);
|
||||
}
|
||||
|
||||
using AsyncUpdater::triggerAsyncUpdate;
|
||||
|
||||
private:
|
||||
static int convertResult (NSModalResponse response)
|
||||
{
|
||||
switch (response)
|
||||
{
|
||||
case NSAlertFirstButtonReturn: return 0;
|
||||
case NSAlertSecondButtonReturn: return 1;
|
||||
|
|
@ -55,9 +63,6 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
using AsyncUpdater::triggerAsyncUpdate;
|
||||
|
||||
private:
|
||||
void handleAsyncUpdate() override
|
||||
{
|
||||
if (auto* comp = options.getAssociatedComponent())
|
||||
|
|
@ -68,24 +73,27 @@ private:
|
|||
{
|
||||
if (auto* window = [view window])
|
||||
{
|
||||
[getAlert() beginSheetModalForWindow: window completionHandler: ^(NSModalResponse result)
|
||||
if (@available (macOS 10.9, *))
|
||||
{
|
||||
handleModalFinished ((int) result);
|
||||
}];
|
||||
[getAlert() beginSheetModalForWindow: window completionHandler: ^(NSModalResponse result)
|
||||
{
|
||||
handleModalFinished (result);
|
||||
}];
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handleModalFinished ((int) [getAlert() runModal]);
|
||||
handleModalFinished ([getAlert() runModal]);
|
||||
}
|
||||
|
||||
void handleModalFinished (int result)
|
||||
void handleModalFinished (NSModalResponse result)
|
||||
{
|
||||
if (callback != nullptr)
|
||||
callback->modalStateFinished (result);
|
||||
callback->modalStateFinished (convertResult (result));
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue