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?
Why this simple app won't compile? [message #58138] Tue, 01 March 2022 20:10 Go to next message
emve is currently offline  emve
Messages: 3
Registered: February 2022
Junior Member
Wrote simple application to test callback(s).
Got stuck here:
close <<= THISBACK(ActionClose);
Please advise, sources attached.
Michal

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 next message
Oblivion is currently offline  Oblivion
Messages: 1091
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

Re: Why this simple app won't compile? [message #58140 is a reply to message #58139] Wed, 02 March 2022 11:53 Go to previous message
emve is currently offline  emve
Messages: 3
Registered: February 2022
Junior Member
Thank you Oblivion.
TYPEDEF in .h file did the trick.
I oversaw it in the examples that I tried to reproduce.
As of using the lambdas for events: YES.
Michal
Previous Topic: how alter name of EditField ?
Next Topic: install u++ in centos 7
Goto Forum:
  


Current Time: Thu Mar 28 22:02:40 CET 2024

Total time taken to generate the page: 0.01217 seconds