Events and Notifications on dialog items
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2021-07-27
05:29 PM
- last edited on
‎2021-09-14
09:25 AM
by
Noemi Balogh
‎2021-07-27
05:29 PM
Hello!
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
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:
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 { public: GS::UniString GetName(); void Do_HTTPRequest();//Based on the name of the button private: GS::UniString name; } class MyButtonObserver : public DG::ButtonItemObserver { }is there any way to override the OnClick event of a button?
Labels:
- Labels:
-
Add-On (C++)
2 REPLIES 2

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2021-07-28 11:11 AM
‎2021-07-28
11:11 AM
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:
Something like this:
MyButton* myButton = dynamic_cast<MyButton*> (ev.GetSource ());
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2021-07-28 01:13 PM
‎2021-07-28
01:13 PM
Thank you!
I tried it and it works.
I tried it and it works.