Event.mouseDown not working

Hello, I struggled the whole day getting a simple editor window to work.

I want to have a EditorWindow in which I can add Actions that are defined in my scripting language (used for bullet type game). The actions are a set of parameters inside a EditorGUILayout.FoldOut. But to be really useful I need these actions to be able to get dragged up and down and nested (just like in the default Hierarchy panel in unity where you can drag gameobjects around and nest them)

I know how to do drag and drop with MouseUp/Down events but I cant get these to work. In the OnGUI function the Event.current.type is never Event.mouseDown when its over one of my FoldOuts, only when its inside the Window itself (which isnt of any use for me).
(this problem also occurs on buttons, not only on foldouts)

Is there any easy way to get better event response?
Thanks in advance

You might check the event type after your foldout. The Event class has a “Use()” method which should be called when a control handles / consumes an event. The moment an event is consumed it will change the type to EventType.Used. This will prevent that other controls can handle the event. The only events that should never be eaten are “Layout” and “Repaint”.

You can either:

  • check the event type at the beginning of OnGUI before you call any control method.
  • or instead of Event.current.type use Event.current.rawType which isn’t modified by Use().