mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
NativeMessageBox: On iOS, prefer the peer of the associatedComponent to the focused peer to determine the parent controller
This commit is contained in:
parent
6bee9d515c
commit
2c5b1fbb6f
1 changed files with 13 additions and 4 deletions
|
|
@ -44,7 +44,7 @@ std::unique_ptr<ScopedMessageBoxInterface> ScopedMessageBoxInterface::create (co
|
|||
|
||||
void runAsync (std::function<void (int)> recipient) override
|
||||
{
|
||||
if (iOSGlobals::currentlyFocusedPeer == nullptr)
|
||||
if (peerToUse == nullptr)
|
||||
{
|
||||
// Since iOS8, alert windows need to be associated with a window, so you need to
|
||||
// have at least one window on screen when you use this
|
||||
|
|
@ -76,9 +76,9 @@ std::unique_ptr<ScopedMessageBoxInterface> ScopedMessageBoxInterface::create (co
|
|||
[alert.get() setPreferredAction: action];
|
||||
}
|
||||
|
||||
[iOSGlobals::currentlyFocusedPeer->controller presentViewController: alert.get()
|
||||
animated: YES
|
||||
completion: nil];
|
||||
[peerToUse->controller presentViewController: alert.get()
|
||||
animated: YES
|
||||
completion: nil];
|
||||
}
|
||||
|
||||
int runSync() override
|
||||
|
|
@ -109,6 +109,15 @@ std::unique_ptr<ScopedMessageBoxInterface> ScopedMessageBoxInterface::create (co
|
|||
|
||||
private:
|
||||
const MessageBoxOptions options;
|
||||
UIViewComponentPeer* peerToUse = std::invoke ([&]() -> UIViewComponentPeer*
|
||||
{
|
||||
if (auto* comp = options.getAssociatedComponent())
|
||||
if (auto* peer = comp->getPeer())
|
||||
return static_cast<UIViewComponentPeer*> (peer);
|
||||
|
||||
return iOSGlobals::currentlyFocusedPeer;
|
||||
});
|
||||
|
||||
NSUniquePtr<UIAlertController> alert;
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MessageBox)
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue