Page 1 of 1

VisualtreeHelper not catching click on ComboBox

Posted: 19 Oct 2014, 17:18
by Mikael Gyth
Hello.
I tried to use VisualTreeHelper to stop clicks from going trough the GUI to the underlaying GameObjects.
And this seem to work fine except when I click on a item in a ComboBox. Is there a way to get around this?

The code I use.
...
        root = Camera.main.GetComponent<NoesisGUIPanel>().GetRoot<Grid>();
    }
...
#if UNITY_EDITOR
    private void OnMouseDown()
    {
        var hit = VisualTreeHelper.HitTest(root, new Point(Input.mousePosition.x, Input.mousePosition.y));
        if (hit.visualHit == null)
        {
            if (_gridMngr.GetCellOccupied())
                _gui.OpenMenuComponent();
            else
                _gui.OpenMenu();
        }
    }
#endif

Re: VisualtreeHelper not catching clik on ComboBox

Posted: 20 Oct 2014, 14:00
by sfernandez
Hi,

Can you please try the following and let me know if it worked, I think we have something wrong in our side:
    Visual root;

    void Start()
    {
        root = VisualTreeHelper.GetRoot(
            Camera.main.GetComponent<NoesisGUIPanel>().GetRoot<Grid>());
    }
...
#if UNITY_EDITOR
    private void OnMouseDown()
    {
        var hit = VisualTreeHelper.HitTest(root, new Point(Input.mousePosition.x, Input.mousePosition.y));
        if (hit.visualHit == null)
        {
            if (_gridMngr.GetCellOccupied())
                _gui.OpenMenuComponent();
            else
                _gui.OpenMenu();
        }
    }
#endif

Re: VisualtreeHelper not catching clik on ComboBox

Posted: 20 Oct 2014, 14:51
by Mikael Gyth
Just tested it and still get clicks trough the ComboBox. (It might be trough all of the GUI but the ComboBox is the only element overlapping the GameObjects)

Re: VisualtreeHelper not catching clik on ComboBox

Posted: 20 Oct 2014, 17:05
by sfernandez
But with my code the HitTest still returns null visualHit?

Re: VisualtreeHelper not catching clik on ComboBox

Posted: 21 Oct 2014, 09:44
by Mikael Gyth
What happens is (With either of the original code or the code provided from you):
- When I click on parts of the GUI (other than the ComboBox) the click doesn't go through. The hit test is not triggered as the underlaying GameObjects aren't hit.
Image
- When I click on the grid the HitTest is triggered and it returns "Noesis.HitTestResult"

- When I click on the ComboBox the click goes through, hits the underlaying GameObject and it returns "Noesis.HitTestResult"
Image

Re: VisualtreeHelper not catching clik on ComboBox

Posted: 21 Oct 2014, 11:41
by sfernandez
Ok, I understand.

I think I found what was wrong in our side. Please overwrite the NoesisUIRenderer.cs script at Assets/Plugins/NoesisGUI/Scripts/Core folder with the one attached here.