- Home /
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
Have you had any luck with this issue? I'm having the same problem. Seems like GUILayout elements eats up the events...
Answer by Bunny83 · Dec 05, 2015 at 04:14 AM
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
useEvent.current.rawType
which isn't modified by Use().
Your answer
![](https://koobas.hobune.stream/wayback/20220611230526im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Can you trigger a function with an event in a base class conditionally? 0 Answers
Is there a smarter way to implement event sequencing? 1 Answer
GUIButton press event takes to long to be called! 1 Answer
listening for events from outside source for iphone 0 Answers
Is there a message/event that I can wait for when object is created in the scene ? 0 Answers