Added click listener to TextButton

This commit is contained in:
andreja6
2018-04-24 12:44:24 -07:00
parent d1a1ebd016
commit f6b301a836
2 changed files with 26 additions and 0 deletions

View File

@@ -42,6 +42,31 @@ TextButtonInstance::TextButtonInstance(void)
disabled = false; disabled = false;
} }
bool TextButtonInstance::mouseInButton(float mousex, float mousey, RenderDevice* rd)
{
Vector3 point1;
Vector3 point2;
if(floatBottom)
{
point1 = Vector3(boxBegin.x, rd->getHeight() + boxBegin.y,0);
point2 = Vector3(boxEnd.x, rd->getHeight() + boxEnd.y,0);
}
else
{
point1 = Vector3(boxBegin.x, boxBegin.y,0);
point2 = Vector3(boxEnd.x, boxEnd.y,0);
}
if(mousex >= point1.x && mousey >= point1.y)
{
if(mousex < point2.x && mousey < point2.y)
{
return true;
}
}
return false;
}
void TextButtonInstance::setAllColorsSame() void TextButtonInstance::setAllColorsSame()
{ {
textColorOvr = textColor; textColorOvr = textColor;

View File

@@ -27,4 +27,5 @@ public:
bool visible; bool visible;
int textSize; int textSize;
void drawObj(RenderDevice*, Vector2, bool); void drawObj(RenderDevice*, Vector2, bool);
bool mouseInButton(float, float, RenderDevice*);
}; };