M
Manuel
I think I can't find this on google/books because is soooooooo basic...
This function assign a listner pointer to an image widget:
------------------------------------------------------
void image::setListener(AbstractListener *listener)
{
this->listener = listener;
}
------------------------------------------------------
this function use the listner:
------------------------------------------------------
bool image::isMouseOver(GLint mouseX, GLint mouseY)
{
bool isOver = false;
if (mouseX > positionX
&& mouseX < positionX + width
&& mouseY > positionY
&& mouseY < positionY + height)
{
listener->mouseOver(mouseX, mouseY, userValue);
isOver = true;
}
return isOver;
};
------------------------------------------------------
Of course, If I call the function above, without call setListner before,
the application crash.
So I must check listner is OK.
I'm trying somewhat like:
------------------------------------------------------
bool image::isMouseOver(GLint mouseX, GLint mouseY)
{
bool isOver = false;
if (mouseX > positionX
&& mouseX < positionX + width
&& mouseY > positionY
&& mouseY < positionY + height)
{
if (listener)
{
listener->mouseOver(mouseX, mouseY, userValue);
}
isOver = true;
}
return isOver;
};
------------------------------------------------------
But it crash anyway...
Please, help...
Regards,
Manuel
This function assign a listner pointer to an image widget:
------------------------------------------------------
void image::setListener(AbstractListener *listener)
{
this->listener = listener;
}
------------------------------------------------------
this function use the listner:
------------------------------------------------------
bool image::isMouseOver(GLint mouseX, GLint mouseY)
{
bool isOver = false;
if (mouseX > positionX
&& mouseX < positionX + width
&& mouseY > positionY
&& mouseY < positionY + height)
{
listener->mouseOver(mouseX, mouseY, userValue);
isOver = true;
}
return isOver;
};
------------------------------------------------------
Of course, If I call the function above, without call setListner before,
the application crash.
So I must check listner is OK.
I'm trying somewhat like:
------------------------------------------------------
bool image::isMouseOver(GLint mouseX, GLint mouseY)
{
bool isOver = false;
if (mouseX > positionX
&& mouseX < positionX + width
&& mouseY > positionY
&& mouseY < positionY + height)
{
if (listener)
{
listener->mouseOver(mouseX, mouseY, userValue);
}
isOver = true;
}
return isOver;
};
------------------------------------------------------
But it crash anyway...
Please, help...
Regards,
Manuel