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

Events and Notifications on dialog items

Mihalcea Bogdan
How can I use the event notifications in Archicad API?
I created a new Button class based on the DG::Button class which has a "name" variable. When I click this button I want to make something happen.
For now I am using
 if(ev.GetSource() == some button) { do something ... }
My problem is that the ev.GetSource() does not return my Button class pointer but it returns DG::ButtonItem pointer which does not contain the newly created functions like GetName().
I even made a new Observer class which inherits the ButtonItemObserver but I am stuck at this. This button will do only one type of thing like a HTTP request based on the name of this button.
To be more clear I will write the code here:

class MyButton : public DG::Button {
      GS::UniString GetName();
      void Do_HTTPRequest();//Based on the name of the button
      GS::UniString name;
class MyButtonObserver : public DG::ButtonItemObserver {
is there any way to override the OnClick event of a button?

Viktor Kovacs
ev.GetSource() will always return a pointer to the base class, so you have to dynamic_cast it to your inherited class.

Something like this:

MyButton* myButton = dynamic_cast<MyButton*> (ev.GetSource ());

Mihalcea Bogdan
Thank you!
I tried it and it works.

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!