Hey,
In implementing my UI I have come to a standstill.
Right now to detect which UI element is being being focused I simply transverse my UI layers top to bottom and check to see if the mouse position is inside the UI elements rect. If it is I check to see if it also is inside one of its children's rect, that way I can always focus the deepest-in-the-hierarchy element.
Consider this simple hierarchy:
- Panel
- TextBox
If my textbox is actually placed outside of the rect of its parent (either the whole textbox or even a part of it) then I will never be able to focus it since I always check from top to bottom in the UI hierarchy. This could be fixed if I forced child UI elements to be inside their parent's rect but I don't like that restriction since it takes away too much flexibility.
Now to solve this I could change my system to use a quad tree in which I would place my UI elements and not only would the whole process be probably much faster but I would get around this last issue. However it would bring about the new issue where I could no longer guarantee that the focused UI element is the deepest in the hierarchy, and this would put me at the mercy of clicking in a text box inside a panel and having the system return me the panel as the focused element instead of the text box.
Any ideas ?
Thanks in advance,
AH