React on button down in Editor GUI

I am looking for a way to determine when a GUI button in the Editor is pressed down and when it is released.

I have used the following code for testing GUILayout.Button:

void OnGUI () {
   bool buttonValue = GUILayout.Button("Button");
   Debug.Log("Button value: " + buttonValue);
}

The boolean returned by GUILayout.Button seems to only return TRUE once whenever the button is released, and FALSE at all other times.

Does anyone know how I can determine if the button has been pressed down?

you have use static variable ‘Event.current’ to whether ‘isMouse’ property is true and then check for ‘button’ property to check witch mouse button is down. also you have to know rectangle of your button and check whether mousePosition is inside rectangle of button.

something like this :

// assume this is area of your button
Rect buttonArea = new Rect(5,5,100,30);
Event e = Event.current;
if(e != null)
{
    if(e.isMouse && e.button  == 0 && buttonArea.Contains(e.mousePosition))
    {
        // then left mouse button is down
    }
}

For reference I ended up with the following code:

void OnGUI () {
	Event e = Event.current;
	
	GUIContent buttonText = new GUIContent("Button");
	Rect buttonRect = GUILayoutUtility.GetRect(buttonText, GUIStyle.none); 
	
	if (e.isMouse && buttonRect.Contains(e.mousePosition)) { 
    	Debug.Log("Mouse pressed: " + (e.type == EventType.MouseDown));
	} 
	
	GUI.Button(buttonRect, buttonText);
}