Developer forum
cancel
Showing results for 
Search instead for 
Did you mean: 

EventNotifier for Browser Control

Chris Howell
Participant
Hi, Archicad dev teams
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
1 ACCEPTED SOLUTION

Solution
VEGH
Graphisoft
Graphisoft

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);

}

View solution in original post

1 REPLY 1

Solution
VEGH
Graphisoft
Graphisoft

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);

}

View solution in original post

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!