Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous message
lectus is currently offline  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);
}
 
Read Message
Read Message
Read Message
Previous Topic: Zooming layouts and different behaviour windows/linux
Next Topic: QTF tooltip on tray icon.
Goto Forum:
  


Current Time: Mon May 13 03:03:16 CEST 2024

Total time taken to generate the page: 0.02196 seconds