2021-08-23 02:59 PM - last edited on 2021-09-14 09:19 AM by Noemi Balogh
static bool HandleDownloadingEvent(const DG::BrowserBase& source, const DG::BrowserDownloadingArg &args);
void BrowserPalette::InitBrowserControl()
{
GS::UniString url = this->GetSiteUrl();
DBASSERT(!url.IsEmpty());
this->m_browser.LoadURL(url);
this->m_browser.DisableContextMenu();
this->RegisterAPIJavaScriptObject();
this->m_browser.onDownloading += DG::EventNotifier<DG::BrowserBase, DG::BrowserDownloadingArg, bool, true>::Runnable(&BrowserPalette::HandleDownloadingEvent);
}
bool BrowserPalette::HandleDownloadingEvent(const DG::BrowserBase& source, const DG::BrowserDownloadingArg &args)
{
if (source.GetDefaultEventTarget() == nullptr)
return false;
if (args.isComplete)
{
return true;
}
return false;
}
Error:
error C2338: Second argument must be EventArg&!
error C2440: '<function-style-cast>': cannot convert from 'const std::function<bool (const DG::BrowserBase &,DG::BrowserDownloadingArg &)>' to 'DG::EventNotifier<DG::BrowserBase,const DG::BrowserDownloadingArg,bool,true>::RunnableHelper'
Solved! Go to Solution.
2021-09-07 11:52 AM - last edited on 2021-09-08 09:11 PM by Laszlo Nagy
Please try to add the event handler with Add instead of +=.
And use a non static member function:
class BrowserPalette: ...,
{
...
bool HandleDownloadingEvent (const DG::BrowserBase& source, const DG::BrowserDownloadingArg& args);
};
BrowserPalette::BrowserPalette (...)
{
browser.onDownloading.Add (&BrowserDialog::HandleDownloadingEvent, this);
}
2021-09-07 11:52 AM - last edited on 2021-09-08 09:11 PM by Laszlo Nagy
Please try to add the event handler with Add instead of +=.
And use a non static member function:
class BrowserPalette: ...,
{
...
bool HandleDownloadingEvent (const DG::BrowserBase& source, const DG::BrowserDownloadingArg& args);
};
BrowserPalette::BrowserPalette (...)
{
browser.onDownloading.Add (&BrowserDialog::HandleDownloadingEvent, this);
}