2020-01-26 11:36 PM
Hello I am really new to both C++ and Touch GFX and trying to put a click listener to scrollWhell so that user will be able to go to chosen screnn from the scrollWhell. This is my MenuView.hpp:
public:
.
.
.
void ScrollWheelClickHandler(const ScrollWheel& b, const ClickEvent& e);
protected:
.
.
Callback<MenuView, const ScrollWheel&, const ClickEvent&> ScrollWhellClickedCallback;
And this is my MenuView.cpp:
MenuView::MenuView()
{
ScrollWhellClickedCallback(this,&MenuView::ScrollWheelClickHandler){}
}
void MenuView::setupScreen()
{
.
.
scrollWheel.setClickAction(ScrollWhellClickedCallback);
}
void MenuView::ScrollWheelClickHandler(const ScrollWheel& b, const ClickEvent& evt)
{
if (&b == &scrollWheel)
{
//bla bla
}
}
But the compiler gives an "call of an object of a class type without appropriate operator() or conversion functions to pointer-to-function type" error. In the line:
MenuView::MenuView()
{
ScrollWhellClickedCallback(this,&MenuView::ScrollWheelClickHandler){}
}
How can I fix this error? Thanks beforehand.
Solved! Go to Solution.
2020-01-27 12:22 AM
I think you just need to move it to the initialization list of MenuView. Like this:
MenuView::MenuView()
: ScrollWhellClickedCallback(this,&MenuView::ScrollWheelClickHandler)
{
}
Currently you are trying to call the ScrollWhellClickedCallback which the compiler doesn't know how to do, but moving it to the initialization list will let the compiler now you want to initialize it instead.
2020-01-27 12:22 AM
I think you just need to move it to the initialization list of MenuView. Like this:
MenuView::MenuView()
: ScrollWhellClickedCallback(this,&MenuView::ScrollWheelClickHandler)
{
}
Currently you are trying to call the ScrollWhellClickedCallback which the compiler doesn't know how to do, but moving it to the initialization list will let the compiler now you want to initialize it instead.
2020-01-27 12:28 AM
Yes that fixed it, thank you!