- Mikael Gyth
- Posts: 33
- Joined:
VisualtreeHelper not catching click on ComboBox
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.
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.
Code: Select all
...
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
Last edited by Mikael Gyth on 23 Oct 2014, 09:08, edited 1 time in total.
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: VisualtreeHelper not catching clik on ComboBox
Hi,
Can you please try the following and let me know if it worked, I think we have something wrong in our side:
Can you please try the following and let me know if it worked, I think we have something wrong in our side:
Code: Select all
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
- Mikael Gyth
- Posts: 33
- Joined:
Re: VisualtreeHelper not catching clik on ComboBox
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)
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: VisualtreeHelper not catching clik on ComboBox
But with my code the HitTest still returns null visualHit?
- Mikael Gyth
- Posts: 33
- Joined:
Re: VisualtreeHelper not catching clik on ComboBox
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.
- 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"
- 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.
- 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"
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: VisualtreeHelper not catching clik on ComboBox
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.
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.
- Attachments
-
- NoesisUIRenderer.zip
- (4.16 KiB) Downloaded 137 times
Who is online
Users browsing this forum: Google [Bot] and 15 guests