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 » Community » Newbie corner » Why this simple app won't compile?
Re: Why this simple app won't compile? [message #58139 is a reply to message #58138] Tue, 01 March 2022 22:57 Go to previous messageGo to previous message
Oblivion is currently offline  Oblivion
Messages: 1092
Registered: August 2007
Senior Contributor
Hello Michal, welcome to the U++ forums.

First things first: callbacks and callback macros are deprecated. See: https://www.ultimatepp.org/src$Core$Callbacks_en-us.html

Also on the same page:

Quote:

Callback macros reduce verbosity of instance method callbacks. They expect CLASSNAME to be typedef-ed as the type of current class and return method callbacks bound to the this pointer.


This means that in order to use instance methods as callbacks, you need to add the following line to your class:



class MichaluvTest : public WithMichaluvTestLayout<TopWindow> {
public:
	void ActionClose();
	MichaluvTest();
	typedef MichaluvTest CLASSNAME; // <------
};




But, I suggest you using the "modern" way (lambdas), this way you wouldn't need the above tweak (i.e. typedefing the CLASSNAME)

MichaluvTest::MichaluvTest()
{
	CtrlLayout(*this, "Window title");
	close << [=] { Break(); }; // 1) We use a lambda function to define the event.
                                   // 2) The method to break the main loop is Break(), not Breaker()
}

GUI_APP_MAIN
{
	MichaluvTest().Run();
}



Best regards,
Oblivion


[Updated on: Tue, 01 March 2022 22:59]

Report message to a moderator

 
Read Message
Read Message
Read Message
Previous Topic: how alter name of EditField ?
Next Topic: install u++ in centos 7
Goto Forum:
  


Current Time: Thu Apr 18 11:35:06 CEST 2024

Total time taken to generate the page: 0.02304 seconds