#include "MenuButton.h"
#include "Shapes.h"
#include "VotePage.h"
#include <iostream>
MenuButton::MenuButton()
{
//ctor
}
MenuButton::~MenuButton()
{
//dtor
}
bool MenuButton::checkMouseCoordinate(float bClickX, float bClickY, sf::RenderWindow &VoteApp, int &buttonSwitch, int &buttonNum , bool is_votePage)
{
if( bClickX > 25 && bClickX < 222 && bClickY > 642 && bClickY < 721) //button 1, authorized info
{
buttonNum = 1;
buttonSwitch = 1;
shapes_changeColor.ChangeButtonColor(VoteApp,buttonNum);
// shapes_changeColor.setButtonColor(VoteApp,button);
// shapes_changeColor.Draw( VoteApp , button);
}
else if ( bClickX > 228 && bClickX < 429 && bClickY > 642 && bClickY < 721) // button 2, vote candidates
{
buttonNum = 2;
buttonSwitch = 2;
shapes_changeColor.ChangeButtonColor(VoteApp,buttonNum);
// shapes_changeColor.setButtonColor(VoteApp,button);
//shapes_changeColor.Draw( VoteApp, button );
}
else if ( bClickX > 20 && bClickX < 210 && bClickY > 701 && bClickY < 744 && is_votePage == true) //button 3, in vote page when b_votePage == true, back to main button
{
buttonNum = 3;
buttonSwitch = 3;
}
else if ( bClickX > 368 && bClickX < 446 && bClickY > 703 && bClickY < 748 && is_votePage == true) //this in vote page, voteNums
{
buttonNum = 4;
buttonSwitch = 4;
vPage_changeColor.Draw(VoteApp,buttonNum); //if i set the bClicks at any other coordiates on the window than what's stated above, this function can take effect.
}
else
{
buttonNum = 0;
buttonSwitch = 0;
shapes_changeColor.ChangeButtonColor(VoteApp,buttonNum);
// shapes_changeColor.setButtonColor(VoteApp,button);
// shapes_changeColor.Draw(VoteApp , button);
}
}
So it only respond to the function effect if it is outside certain coordinate. What's happening?
Others works fine except the range of coordinates I've set here:
else if ( bClickX > 368 && bClickX < 446 && bClickY > 703 && bClickY < 748 && is_votePage == true) //this in vote page, voteNums
{
buttonNum = 4;
buttonSwitch = 4;
vPage_changeColor.Draw(VoteApp,buttonNum); //if i set the bClicks at any other coordiates on the window than what's stated above, this function can take effect.
}