As always, there are different ways to do this. One way would be to first check clicks on the buttons, return a value indicating whether the button was hit or not, and then only handle the click for the background if no button was hit.
I have used a similar method before (code simplified and from memory - not guaranteeing correct syntax, but the principle should be clear):
bool ClickHit(mouse.X, mouse.Y) //inside the button
{
if (this.ScreenRectangle.Intersects(mouse.X, mouse.Y)
{
//do button stuff here or in another place, depending on where it's appropriate
return true;
}
return false;
}
///////////////////////////////////////////////////
bool ButtonHit(mouse.X, mouse.Y) //inside the menu
{
foreach (Button b in this.ButtonList)
{
if (b.ClickHit(mouse.X, mouse.Y))
{
//this might be a place to do button stuff as well
return true;
}
}
return false;
}
//////////////////////////////////////////
if (!Menu.ButtonHit(mouse.X, mouse.Y)) //where you do your other stuff
{
//move your background and do other stuff that you only want to do if no Button was clicked
}
I'm sure there are more elegant solutions, but this one should be relatively simple to include into an existing codebase.