Archicad C++ API
About Archicad add-on development using the C++ API.

How To Fire Click Event from Push Button in Dialog

Anonymous
Not applicable
Please teach me.
How To Fire Click Event from Push Button in Dialog on C++ Code.
DG_Command ?
2 REPLIES 2
Anonymous
Not applicable

I give you an example of how I do it:

The header of your dialog class:

 

 

 

class ExampleDialog : public DG::ModalDialog, 
    public DG::PanelObserver, 
    public DG::ButtonItemObserver, 
    public DG::CompoundItemObserver 
{ 
public: 
    ExampleDialog (GSResModule dialResModule); 
    ~ExampleDialog (); 

private: 
    virtual void PanelOpened(const DG::PanelOpenEvent& ev) override; 
    virtual void ButtonClicked(const DG::ButtonClickEvent& ev) override; 

    static const short DIALOG_ID = 32530; 
    enum 
    { 
        ButtonID = 1, // Id from your .grc file 
    }; 

    DG::Button button_; 
};

 

 

 

Cpp file :

 

 

 

ExampleDialog ::ExampleDialog (GSResModule dialResModule) :
    DG::ModalDialog(dialResModule, DIALOG_ID, dialResModule),
    button_(GetReference(), ButtonID),

{
    AttachToAllItems(*this);
}

void ExampleDialog ::ButtonClicked(const DG::ButtonClickEvent& ev)
{
   ...
}

 

 

 

If something is not clear ask questions, I will try to answer.

Miklos Vegh
Graphisoft
Graphisoft

You can't generate a click evet from the code. But if the click handling statements are in a standalone function, you can call that function in the ButtonClicked notification and anywhere else.