GetMouseButton() blocking input to GUI?

I’ve encountered this odd behavior where calling GetMouseButton() seems to block input to the GUI. Anyone encountered this before or know how to prevent it?

Here’s an example:

string test = "";
void OnGUI()
{
	if(Input.GetMouseButton(0))
	{
		GUI.Box(new Rect(100, 100, 200, 200), "");
	}

	test = GUI.TextField(new Rect(100, 350, 200, 30), test);
}

In this example, holding the mouse down causes the GUI Box to appear, but I can’t click on the Text Field to enter any text.
If I comment out the if(Input.GetMouseButton(0)) then the text field works again.

(If anyone’s wondering why you’d want to draw a box and process a text field at the same time, this is just a simplified example.)

GUI processes one event for a mouse for time. And, Input.GetMouseButton() don’t use in OnGUI(). Only in Update() and LateUpdate(). For OnGUI() use Event. See an example below:

 private bool isPressMouse = false;
 private string test = "";

 void OnGUI() {
  if(Event.current.type == EventType.MouseDown) {
   isPressMouse = true;
  }
  if(Event.current.type == EventType.MouseUp) {
   isPressMouse = false;
  }
  if(isPressMouse) {
   GUI.Box(new Rect(100, 100, 200, 200), "");
  }
  test = GUI.TextField(new Rect(100, 350, 200, 30), test);
 }

I hope that it will help you.