I use a parent/child system, so each 'gadget' has both a parent (even if it's just the screen) and could have zero or more children. Each of those children could also be parents to other children.
Doing that vastly reduces the number of checks you need to make to see which gadget the mouse is over or has clicked.
The image below is from a visual editor that is currently on hold while I watch the fate of TGC's own visual editor. The GUI system is fully functional though and I continue to use that in other tools.
To explain the parent/child relationship with the below image, there are 6 main parents:
1. The design area
2. The menu bar
3. The quick info bar (below the menu)
4. The tool bar (down the left)
5. The properties panel (down the right)
6. The media panel (along the bottom)
I check each of those and only those for mouse events and in that order. We can stop checking parents when we have determined which one the mouse is over. So, if the mouse is over the design area then there is no need to check any gadgets at all.
If the mouse is over the Toolbar, then we've only made 4 checks so far and have determined that we now only need to check the children of the toolbar, which is a maximum of 10 more checks (of course we stop checking once we've found the one we care about)
The Properties panel on the right which is by far the most complex is also subdivded into parent/child to reduce the number of checks.
So, for example, if the mouse is over the flip sprite vertically button we will only need to make 12 mouse area checks. The first five to determine we are over the properties panel, then check 6 (is it over the sprite info area) is FALSE. Check 7 (is it over the sprite offset area) is FALSE etc. down to check 10 (is it over the Flip Sprite are) is TRUE then we can go into the children of this subpanel - Is it over Flip Horizontally = FALSE, is it over flip vertically = TRUE. So display the mouse over image for that button.