Nick Gammon said:
You could, but so far I haven't. I can see quite possibly, especially if you have a tooltip per pixel, dozens of tooltips popping up everywhere driving you mad, like confetti. The current design limits you to one tooltip at a time.
That's fine, I was just proposing a possible fix. It's definitely not a major concern.
Nick Gammon said: Your proposed change of getting a mouse-move message for every time the mouse moves, even by a pixel, would break the documented effect for mouse moves, that you get a mouse-move followed by a mouse-cancel event. Unless you also want a mouse-over cancel event for every pixel as well.
No, not really. The cancelmouseover would only occur when you leave the hotspot, as it is now, and that makes sense to me. The mouseover event just responds as the mouse moves over it.
Nick Gammon said: I can't help feeling you are trying a brute-force approach to a problem that should have a more elegant solution. Surely even nested hotspots can be accommodated by simply keeping them in a table, and finding the topmost one by a quick search?
I find this approach very elegant, personally, but we're allowed to disagree. The issue is that each widget needs some way to keep track of its hotspots, change their handlers, modify their location/size, and remove them if need be, and it is a bonus that the hotspots wouldn't lose their current mouse-state just by getting moved or resized. They would naturally get updated on the next mouse movement, of course, if it moved itself away from the mouse.
Taking this approach - decoupling the hotspots from the events - allows widgets to manage their own hotspots dynamically, without needing to run through complex operations just to make simple changes. I had spent around two or three days just trying to come up with a good design for hotspots, and all of them had some major drawbacks. When I came up with this design, I felt like it was a eureka moment; the only real drawback I could see was the inefficiency of creating so many 1x1 hotspots, which is what I am proposing a (simple) solution to. The layer of hotpixels would track the events, traverse the tree to locate potential callbacks, and execute callbacks when appropriate. The whole widget/hotspot tree can be changed dynamically, and the view need never know.
If you think you have a better solution, I am completely all ears! :) The source is also available on GitHub (now linked in my signature), if you want to look at it for a better idea of what's involved. I'll soon be pushing up a version using the 1x1 blanket of hotpixels, since that approach currently works, if you'd like to see exactly what I'm planning. Most of the infrastructure for the hotspot functionality is already in this version, actually, it's just not exposed.
EDIT: To note, by supplying the flag to enable pixel-sensitive mouse movement, you'd know exactly what would happen. I don't think the documentation issue is a valid concern because of this; just note that the pixel-precision has this behavior and it should be kept in mind while using it. |