cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot create click handler

GunkutA
Senior

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.

1 ACCEPTED SOLUTION

Accepted Solutions
LTimm.1
Associate III

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.

View solution in original post

2 REPLIES 2
LTimm.1
Associate III

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.

GunkutA
Senior

Yes that fixed it, thank you!