As discussed before, I started making my own view class for GLUT, and I made an event handling method that checks for hit rectangles and calls the appropriate method that was passed.
The method looks like this:
The function compiles with no errors, but when I actually use it, there is one error.
The mouse() function is in the main.cpp, which handles drawing, and GLUT events.
The mouseEvent() method is in View.cpp.
Why am I getting this error?
The method looks like this:
Code:
void View::mouseEvent(int x, int y, int button, void (View::*mfunc)(int, int, int))
{
if(pointHitsView(x, y)) (this->*mfunc)(x, y, button);
Enumerator* myEnum = subviews->getEnumerator();
if(myEnum != NULL)
{
View* nextView = (View *)myEnum->getCurrentObject();
while(nextView != NULL)
{
// check hit rect for subview
if(nextView->pointHitsView(x,y)) (nextView->*mfunc)(x, y, button);
nextView = (View *)myEnum->nextObject();
}
}
}
The function compiles with no errors, but when I actually use it, there is one error.
Code:
void mouse(int button, int state, int x, int y)
{
void (View::*eventFunc)(int, int, int) = mouseDownAtPosition;
// this gives me "mouseDownAtPosition was not declared in scope"
outerBox->mouseEvent(x, y, button, eventFunc);
testCell->mouseEvent(x, y, button, eventFunc);
}
The mouse() function is in the main.cpp, which handles drawing, and GLUT events.
The mouseEvent() method is in View.cpp.
Why am I getting this error?