cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 
Martin Walter
Enthusiast

Handle events from browser control DG::Browser

How can I recognize an event from the browser control DG::Browser, for example the URLChanged which is declared in BrowserBase?
AC22-27, Windows 11, i7-1355U, 32GB RAM, 2TB SSD
1 Solution

Accepted Solutions
Martin Walter
Enthusiast
Obviously the callback function can not be defined in a class. I got it working finally this way:

void handleURLChanged(const DG::BrowserBase& source, const DG::BrowserURLChangedArg& eventArg);

m_browser.urlChanged += DGEventNotifier<DG::BrowserBase, DG::BrowserURLChangedArg>::Runnable(&handleURLChanged);
AC22-27, Windows 11, i7-1355U, 32GB RAM, 2TB SSD

Go to post

6 Replies 6
Use the += operator of BrowserBase::urlChanged to add a Runnable callback function to respond to this event.
Ralph Wessel BArch
Central Innovation
Martin Walter
Enthusiast
Sorry I'm not able to make it. My code does not compile in this line:
DGEventNotifier<BrowserBase, DG::BrowserURLChangedArg>::Runnable func = &UIBrowser::URLChanged;
Can you please tell me what is wrong?

My whole code is:

class UIBrowser: public DG::Browser
{
public:
	UIBrowser(const DG::Panel& panel, short item);

private:
	virtual void URLChanged(const DG::BrowserURLChangedArg& eventArg) override;
};

UIBrowser::UIBrowser(const DG::Panel& panel, short item) :
	DG::Browser(panel, item)
{
	DGEventNotifier<BrowserBase, DG::BrowserURLChangedArg>::Runnable func = &UIBrowser::URLChanged;
	this->urlChanged += func;
}

void UIBrowser::URLChanged(const DG::BrowserURLChangedArg& eventArg)
{
...
}
AC22-27, Windows 11, i7-1355U, 32GB RAM, 2TB SSD
Martin wrote:
I'm not able to make it. My code does not compile in this line:
DGEventNotifier<BrowserBase, DG::BrowserURLChangedArg>::Runnable func = &UIBrowser::URLChanged;
Try changing this to:
this->urlChanged += DGEventNotifier<DG::BrowserBase, DG::BrowserURLChangedArg>::Runnable(UIBrowser::URLChanged);
Ralph Wessel BArch
Central Innovation
Martin Walter
Enthusiast
that doesn't compile too.
and neither:
this->urlChanged += DGEventNotifier<DG::BrowserBase, DG::BrowserURLChangedArg>::Runnable(&UIBrowser::URLChanged);
AC22-27, Windows 11, i7-1355U, 32GB RAM, 2TB SSD
The urlChanged function should look more like this:
void UIBrowser::URLChanged(const DG::BrowserBase& source, const DG::BrowserURLChangedArg& eventArg)
Ralph Wessel BArch
Central Innovation
Martin Walter
Enthusiast
Obviously the callback function can not be defined in a class. I got it working finally this way:

void handleURLChanged(const DG::BrowserBase& source, const DG::BrowserURLChangedArg& eventArg);

m_browser.urlChanged += DGEventNotifier<DG::BrowserBase, DG::BrowserURLChangedArg>::Runnable(&handleURLChanged);
AC22-27, Windows 11, i7-1355U, 32GB RAM, 2TB SSD

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!