When pressed TButton calls function?


Is it possible for TButton to call a C++ function (class member or global) when pressed?

I would like to make a regular TCanvas and plot some graphics on it. I would like to be able to update canvas every time a button is pressed and I thought to use TButton to do this. Is there a better way to do this task?

Thank you,

See the example here:
You can execute a macro or C++ code

Thanks for the suggestion.

Yes, I saw this but could not get this to work. It turns out that one needs to compile a dictionary for the “button_called_function” - this works now.

void button_called_function()

int WaitForButton(const std::string &canvas)
TDialogCanvas *dialog = new TDialogCanvas(canvas.c_str(), “”, 150, 50);

TButton *but1 = new TButton(“Next”, “button_called_function()”, 0.05, 0.05, 0.95, 0.95);

return 1;

So it works now ?
Note you can also execute a macro.

This works now - thanks!

By the way, I am just trying to write a simple equivalent of TCanvas::WaitPrimitive function that uses an explicit “next” button instead of double-click because my X session is very slow and double-click often does not register. Is there a better way to do this?

Thank you,

That’s a good way I guess…