Home » U++ Library support » U++ Widgets - General questions or Mixed problems » What is best way to obtain button info via callback?
Re: What is best way to obtain button info via callback? [message #36714 is a reply to message #13586] |
Thu, 28 June 2012 16:14 |
lectus
Messages: 329 Registered: September 2006 Location: Brazil
|
Senior Member |
|
|
Thanks for opening my eyes for this!
We can use one callback to handle all buttons and this keeps the code much more organized:
enum {btn1, btn2};
void MainWin::SetEditOutput(int n)
{
switch (n) {
case btn1:
output <<= "You clicked button 1";
break;
case btn2:
output <<= "You clicked button 2";
break;
}
}
MainWin::MainWin()
{
CtrlLayout(*this, "Window title");
button1.WhenPush = THISBACK1(SetEditOutput, btn1);
button2.WhenPush = THISBACK1(SetEditOutput, btn2);
}
|
|
|
Goto Forum:
Current Time: Mon May 13 03:03:16 CEST 2024
Total time taken to generate the page: 0.02196 seconds
|