Basically, I have a drop-down menu and when you click on the menu the drop-down list will appear. However, when you try to click away from the drop down menu to close it, the drop down menu should disappear. It does change back to it's orgininal image, however the old image is still located on the screen. Any ideas?
This is the input function : -
Code: Select all
void System::Handle_Input(SDL_Event event)
{
SDL_Flip(Buffer);
int x = 0;
int y = 0;
bool test = true;
if(event.type == SDL_MOUSEMOTION)
{
x = event.motion.x;
y = event.motion.y;
if((x > CoordsSaveButton.x) && (x < CoordsSaveButton.x + CoordsSaveButton.w) && (y > CoordsSaveButton.y) && (y < CoordsSaveButton.y + CoordsSaveButton.h))
{
SaveMenuStatus = SaveMenuSelected;
}
else
{
SaveMenuStatus = SaveMenu;
}
if((x > CoordsLoadButton.x) && (x < CoordsLoadButton.x + CoordsLoadButton.w) && (y > CoordsLoadButton.y) && (y < CoordsLoadButton.y + CoordsLoadButton.h))
{
LoadMenuStatus = LoadMenuSelected;
}
else
{
LoadMenuStatus = LoadMenu;
}
}
if(event.type == SDL_MOUSEBUTTONDOWN)
{
if(event.button.button == SDL_BUTTON_LEFT)
{
x = event.button.x;
y = event.button.y;
if((x > CoordsTileButton.x) && (x < CoordsTileButton.x + CoordsTileButton.w) && (y > CoordsTileButton.y) && (y < CoordsTileButton.y + CoordsTileButton.h))
{
TileMenuStatus = TileMenuSelected;
}
else
{
TileMenuStatus = TileMenu;
}
}
}
}
Code: Select all
void System::show()
{
if(SaveMenuStatus == SaveMenu)
{
Apply_Image(500,110, SaveMap, Buffer);
}
else if (SaveMenuStatus == SaveMenuSelected)
{
Apply_Image(500,110, SaveSelected, Buffer);
}
if (LoadMenuStatus == LoadMenu)
{
Apply_Image(500,80, LoadMap, Buffer);
}
else if (LoadMenuStatus == LoadMenuSelected)
{
Apply_Image(500,80, LoadSelected, Buffer);
}
if (TileMenuStatus == TileMenu)
{
Apply_Image(500,15, MenuSelection, Buffer);
}
else if (TileMenuStatus == TileMenuSelected)
{
Apply_Image(500,15, MenuSelection1 , Buffer);
}
SDL_Flip(Buffer);
}