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: 10 Registered: February 2022
|
Promising 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: 1204 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
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Tue, 01 March 2022 22:59] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Sat May 03 14:42:44 CEST 2025
Total time taken to generate the page: 0.03915 seconds
|