Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NodeEditorAction eats hotControl #45

Closed
RavaGames opened this issue Jun 19, 2018 · 2 comments
Closed

NodeEditorAction eats hotControl #45

RavaGames opened this issue Jun 19, 2018 · 2 comments
Labels

Comments

@RavaGames
Copy link
Contributor

RavaGames commented Jun 19, 2018

Issue:
It seems that NodeEditorAction (NEA) is eating the hotControl before the button click is registered.

I've narrowed it down to the below section of NEA, specifically setting the hotControls to zero, but I don't know how to properly fix it myself without potentially breaking something else:

else if (!IsHoveringNode) {
	// If click outside node, release field focus
	if (!isPanning) {

		// I've got no idea which of these do what, so we'll just reset all of it.
		GUIUtility.hotControl = 0;
		GUIUtility.keyboardControl = 0;
		EditorGUIUtility.editingTextField = false;
		EditorGUIUtility.keyboardControl = 0;
		EditorGUIUtility.hotControl = 0;
	}
	if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
}

Situation:
I'm trying to add a global controls box in the corner of the xNode window using my graph's custom editor's OnGUI.

unknown

Example implementation: https://github.com/dashrava/xNode/tree/hotControlIssue
(Usage: Open graph.asset, try to press button before and after panning.)

Relevant code bit:

[CustomNodeGraphEditor(typeof(NewNodeGraph))]
public class NewNodeGraphEditor : NodeGraphEditor
{

    public override void OnGUI()
    {
        base.OnGUI();

        if (GUILayout.Button("this button doesn't log anything unless you pan or modify NEA"))
        {
            Debug.Log("CLICK");
        }
    }
}

Further information:
I tried to call use() on the current event when the graph editor's OnGUI button is clicked, but it seems that NEA has priority and clears the control before the button click goes through properly.

The control box buttons (used to zoom in the below gif) work after panning:
nea

Considerations:
Is it necessary to reset the hotControl in the first place?

The control box obviously isn't IsHoveringNode.
Is there a way to check that the click is specifically on the editor's background?

@Siccity Siccity added the bug label Jun 19, 2018
@RavaGames
Copy link
Contributor Author

Added link to example branch for easier repro. Tested with fresh fork of the master branch (on Unity 2018.1)

@Siccity
Copy link
Owner

Siccity commented Jun 20, 2018

Fixed ba3c8bd

@Siccity Siccity closed this as completed Jun 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants