private bool DoRemoveButton(Rect position, bool visible)
{
int controlID = GUIUtility.GetControlID(FocusType.Passive);
Vector2 mousePosition = GUIUtility.ScreenToGUIPoint(s_MousePosition);
switch (Event.current.GetTypeForControl(controlID)) {
case EventType.MouseDown:
// Do not allow button to be pressed using right mouse button
// since context menu should be shown instead!
if (GUI.enabled && Event.current.button != 1 && position.Contains(mousePosition)) {
GUIUtility.hotControl = controlID;
GUIUtility.keyboardControl = 0;
Event.current.Use();
}
break;
case EventType.MouseDrag:
if (GUIUtility.hotControl == controlID)
Event.current.Use();
break;
case EventType.MouseUp:
if (GUIUtility.hotControl == controlID) {
GUIUtility.hotControl = 0;
if (position.Contains(mousePosition)) {
Event.current.Use();
return true;
}
else {
Event.current.Use();
return false;
}
}
break;
case EventType.Repaint:
if (visible) {
var content = (GUIUtility.hotControl == controlID && position.Contains(mousePosition))
? s_RemoveButtonActiveContent
: s_RemoveButtonNormalContent;
removeButtonStyle.Draw(position, content, controlID);
}
break;
}
return false;
}