Ah! Okay, so it wasn’t a natively implemented feature after all. Your new method there seems like it’d do exactly what I was expecting. That would allow the sort of focus switching I was thinking about. Thanks for taking the time to answer my question.
Since it’s on my mind, I’ll take a moment to backseat program since I’ve been thinking about this. You probably already solved all these issues and are aware of them, but figured I’d throw it out there anyway.
It might be good to store a record of the most previously ‘touched/active’ widget and check that one first. My thought there is that it looks like there could be a scenario where two windows are overlapping which might cause a conflict.
Say window A and window B. Window B is visually overlayed half way over window A and is the current focus of the user. Then the mouse cursor enters into the intersection point of window A and B.
In that scenario, two widgets are viable return values in GetTopWidget(), but again only the first one iterated will returned(which may even be window A in this case, even though visually B overlays it).
An alternative would be that it checks what the current ‘touch focused’ widget is. If its bounds contain the touch, return that one. If they don’t, a new window is being touched. Set that new window as a the current active ‘touch focus’ and then return it instead.
The tricky thing is that you could still want a scenario in which window A becomes the new touch focus, but window B still has keyboard/input focus because the user hasen’t actually ‘clicked/touchedDown’ window A yet.
Also, rendering order is a thing. Rather than rendering in order of the observable collection, it might make sense to have a history of the order of previously focused widgets and render in that order instead. So if window A was the last window the user interacted with, it’s at the bottom of the list, followed by C, and finally B the currently active window.
Actually thinking out loud like this helps me a lot with my own ideas. Thanks again.
Anyway, i’ll stop rambling and presuming to code Myra in my head.