Buttons in window problem

I have this window with a set of buttons in it. These buttons get made by a loop pulling information from somewhere else. It works all fine until I go to try and click a button. When I hover of the button, it looks like it gets pushed, but it is not being pushed. Then pushing the button doesn’t work as well. Any ideas why?

    function gameWindow(id : int){
	var a : int = gameList.gameCount;
	var yLoc : int = -35; 
	
	for(var x = 0; x < a; x++){
		yLoc += 45;
		var gameID : int = game.id[x];
		var turnNumber : int = game.turn[x];
		var button = GUI.Button(Rect(10, yLoc, 780, 35), "Game ID: " + gameID + "   " + "Turns Completed: " + turnNumber);
		if(button){
			Debug.Log("It worked! " + gameID);
		}
	
	}
	 GUI.BringWindowToBack(0);
	 GUI.UnfocusWindow();

}

function OnGUI () {
	GUI.Window (0, Rect(Screen.width/2 - 400, Screen.height/2 - 300, 800, 600), gameWindow, "");
	
	
}

It looks like it doesn’t get pressed, because it must be pressed the moment it is drawn, or something in this manner. GUI.RepeatButton works, however, because it can be already clicked. But GUI.RepeatButtun gives you “It worked” like every time it gets drawn or so, so very often. There might be a better solution, but I cannot see one.

Remove those two lines:

GUI.BringWindowToBack(0);
GUI.UnfocusWindow();

You unfocus the window every frame. You can never use any GUI element in the window this way.