mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added a callback WebBrowserComponent::windowCloseRequest()
This commit is contained in:
parent
eefbcef611
commit
d226fea10e
6 changed files with 27 additions and 13 deletions
|
|
@ -144,4 +144,9 @@ namespace juce
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if JUCE_WEB_BROWSER
|
||||
bool WebBrowserComponent::pageAboutToLoad (const String&) { return true; }
|
||||
void WebBrowserComponent::pageFinishedLoading (const String&) {}
|
||||
void WebBrowserComponent::windowCloseRequest() {}
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,6 +93,11 @@ public:
|
|||
/** This callback happens when the browser has finished loading a page. */
|
||||
virtual void pageFinishedLoading (const String& url);
|
||||
|
||||
/** This callback occurs when a script or other activity in the browser asks for
|
||||
the window to be closed.
|
||||
*/
|
||||
virtual void windowCloseRequest();
|
||||
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
void paint (Graphics&) override;
|
||||
|
|
@ -120,4 +125,4 @@ private:
|
|||
|
||||
|
||||
#endif
|
||||
#endif // JUCE_WEBBROWSERCOMPONENT_H_INCLUDED
|
||||
#endif // JUCE_WEBBROWSERCOMPONENT_H_INCLUDED
|
||||
|
|
@ -107,6 +107,3 @@ void WebBrowserComponent::visibilityChanged()
|
|||
{
|
||||
checkWindowAssociation();
|
||||
}
|
||||
|
||||
bool WebBrowserComponent::pageAboutToLoad (const String&) { return true; }
|
||||
void WebBrowserComponent::pageFinishedLoading (const String&) {}
|
||||
|
|
|
|||
|
|
@ -112,6 +112,3 @@ void WebBrowserComponent::visibilityChanged()
|
|||
{
|
||||
checkWindowAssociation();
|
||||
}
|
||||
|
||||
bool WebBrowserComponent::pageAboutToLoad (const String&) { return true; }
|
||||
void WebBrowserComponent::pageFinishedLoading (const String&) {}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ struct DownloadClickDetectorClass : public ObjCClass <NSObject>
|
|||
addMethod (@selector (webView:decidePolicyForNavigationAction:request:frame:decisionListener:),
|
||||
decidePolicyForNavigationAction, "v@:@@@@@");
|
||||
addMethod (@selector (webView:didFinishLoadForFrame:), didFinishLoadForFrame, "v@:@@");
|
||||
addMethod (@selector (webView:willCloseFrame:), willCloseFrame, "v@:@@");
|
||||
|
||||
registerClass();
|
||||
}
|
||||
|
|
@ -60,6 +61,11 @@ private:
|
|||
getOwner (self)->pageFinishedLoading (nsStringToJuce ([url absoluteString]));
|
||||
}
|
||||
}
|
||||
|
||||
static void willCloseFrame (id self, SEL, WebView*, WebFrame*)
|
||||
{
|
||||
getOwner (self)->windowCloseRequest();
|
||||
}
|
||||
};
|
||||
|
||||
#else
|
||||
|
|
@ -346,6 +352,3 @@ void WebBrowserComponent::visibilityChanged()
|
|||
{
|
||||
checkWindowAssociation();
|
||||
}
|
||||
|
||||
bool WebBrowserComponent::pageAboutToLoad (const String&) { return true; }
|
||||
void WebBrowserComponent::pageFinishedLoading (const String&) {}
|
||||
|
|
|
|||
|
|
@ -158,6 +158,16 @@ private:
|
|||
owner.pageFinishedLoading (getStringFromVariant (pDispParams->rgvarg[0].pvarVal));
|
||||
return S_OK;
|
||||
}
|
||||
else if (dispIdMember == DISPID_WINDOWCLOSING)
|
||||
{
|
||||
owner.windowCloseRequest();
|
||||
|
||||
// setting this bool tells the browser to ignore the event - we'll handle it.
|
||||
if (pDispParams->cArgs > 0 && pDispParams->rgvarg[0].vt == (VT_BYREF | VT_BOOL))
|
||||
*pDispParams->rgvarg[0].pboolVal = VARIANT_TRUE;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
|
@ -305,6 +315,3 @@ void WebBrowserComponent::visibilityChanged()
|
|||
{
|
||||
checkWindowAssociation();
|
||||
}
|
||||
|
||||
bool WebBrowserComponent::pageAboutToLoad (const String&) { return true; }
|
||||
void WebBrowserComponent::pageFinishedLoading (const String&) {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue