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  |
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   |
Oblivion
Messages: 961 Registered: August 2007
|
Experienced 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
upp-components: https://github.com/ismail-yilmaz/upp-components
[Updated on: Tue, 01 March 2022 22:59] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Tue Jun 28 05:05:29 CEST 2022
Total time taken to generate the page: 0.02219 seconds
|