Anyone have an idea why I receive two mouse down events from this code?
static var MouseDownButtonHash : int = "MouseDownButton".GetHashCode();
static function MouseDownButton(position : Rect, content : GUIContent, style : GUIStyle) : boolean {
var controlID : int = GUIUtility.GetControlID(MouseDownButtonHash, FocusType.Native);
var eventType : EventType = Event.current.GetTypeForControl(controlID);
if (eventType == EventType.mouseDown) {
if (position.Contains(Event.current.mousePosition)) {
GUIUtility.hotControl = controlID;
Event.current.Use();
return true;
}
} else if (eventType == EventType.mouseUp) {
if (GUIUtility.hotControl == controlID) {
GUIUtility.hotControl = 0;
Event.current.Use();
}
} else if (eventType == EventType.repaint) {
style.Draw(position, content, controlID);
}
return false;
}
This sometimes return true twice when clicking once. Any ideas?