Seneral / Node_Editor_Framework

A flexible and modular Node Editor Framework for creating node based displays and editors in Unity
https://nodeeditor.seneral.dev
MIT License
2k stars 415 forks source link

malfunctioning of EditorGUILayout.Popup #170

Closed prasengan closed 5 years ago

prasengan commented 5 years ago

selecting editor/enum pop up of unselected node results in selection changes of selected popup this can even be observed in calculation graph example

Seneral commented 5 years ago

Hey, sorry, for some reason I stopped receiving notifications from github. This is a known issue actually, because the popup is some kind of system level control, it does not let through clicks until after the popup is closed. That then results in a different node being pushed ontop and the due to the way IMGUI works this messes with the focussed control. To fix it, you could disable the reordering of nodes on selection (which is used to put the current node ontop in case of overlapping nodes). You can find it it here.

prasengan commented 5 years ago

this issue was because you returned when event was used , editor popups set event as used
private static void CallEventHandlers (NodeEditorInputInfo inputInfo, bool late) { object[] parameter = new object[] { inputInfo }; foreach (KeyValuePair<EventHandlerAttribute, Delegate> eventHandler in eventHandlers) { if ((eventHandler.Key.handledEvent == null || eventHandler.Key.handledEvent == inputInfo.inputEvent.type) && (late? eventHandler.Key.priority >= 100 : eventHandler.Key.priority < 100)) { // Event is happening and specified priority is ok with the late-state eventHandler.Value.DynamicInvoke (parameter); if (inputInfo.inputEvent.type == EventType.Used) return; } } } I have current used this as fix- [EventHandlerAttribute(-1)] // Absolute third to call! to set focus private static void HandleSelection(NodeEditorInputInfo inputInfo) { if (Event.current.clickCount < 1) { return; }

        NodeEditorState state = inputInfo.editorState;
        if (inputInfo.inputEvent.button == 0 && state.focusedNode != state.selectedNode)
        { // Select focussed Node
            //unfocusControlsForState = state;
            state.selectedNode = state.focusedNode;
            //NodeEditor.RepaintClients();
        }

if UNITY_EDITOR

        if (state.selectedNode != null)
            UnityEditor.Selection.activeObject = state.selectedNode;

endif

    }

this would be a more expensive operation but no issues for editor only use

Seneral commented 5 years ago

Hm interesting, will take a look if that can be used to fix it. Thanks!

Seneral commented 5 years ago

Finally got to merge it, sorry for the delay.