EventNotifier for Browser Control
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2021-08-23
02:59 PM
- last edited on
‎2021-09-14
09:19 AM
by
Noemi Balogh
I am developing the Add-on in Archicad 24 using Browser control.
I tried to handle downloading event but I can't build the project.
Please help me.
This is my code.
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'
Kind Regards,
Chris
Solved! Go to Solution.
- Labels:
-
Add-On (C++)
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎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);
}