I seem to be unable to create 1x1 hotspots, i.e. hotspots that only affect a single pixel. I'm trying to layer a window entirely in 1x1 hotspots for fine-tuned tracking of the mouse using the below code, and for testing purposes I'm using the hotspot's ID as the tooltip text. The problem is that no tooltip appears at all, no matter where I point the mouse.
If I make the hotspots 2x2 instead, and change the for-loops to have a step of 2 instead of the default of 1, everything works fine. 2x2 isn't sufficient for my purposes, though, and it seems odd that 1x1 wouldn't work - it seems perfectly valid.
Another issue is that this takes a long time to execute, taking around 2 seconds on a 184x299 window. I think it wouldn't be such a bad idea to start using the 'flags' parameter to WindowAddHotspot, allowing you to modify the behavior of a single hotspot to send mouseover events for every mouse movement within the area, rather than just crossing into it from the outside. That way, I could just use one large hotspot instead of hundreds of tiny ones.
For reference, the reason I am doing this is because it provides the most convenient and intuitive way to create an abstraction layer over MUSHclient hotspots, allowing each widget in my framework to manage its own set of Hotspot objects (even if the widget is a child (contained within) of another widget). This solves the issue of how to percolate hotspot changes from subwidgets up to the visible frame, because my abstraction layer (implemented by the set of generic handlers you see in the code above) can use the information available to them to travel down the tree of subwidgets to locate the appropriate Hotspot to trigger.
Of course, if anyone has any other ideas I'm all ears, but I've been thinking about this for quite a while and I think it's the most viable way to go about it. After all, I think Win32 sends mouse-movement messages to its windows for every twitch of the mouse, doesn't it? So there is definitely precedent. [1]
[1] http://msdn.microsoft.com/en-us/library/ms645616(VS.85).aspx
EDIT: tl;dr summary, because I think I rambled a bit there:
* 1x1 hotspots seem to be malfunctioning, though I could just be doing something wrong.
* Fine-tuned mouse movement notification within a given hotspot would make a great flag for the unused 'flags' parameter in WindowAddHotspot.
for y = 0, self.height do
for x = 0, self.width do
local id = self.name .. "-h(" .. x .. "," .. y .. ")"
check(WindowAddHotspot(self.name, id, x, y, x+1, y+1,
"MWidget.View.hotspot_handlers.mouseover",
"MWidget.View.hotspot_handlers.cancelmouseover",
"MWidget.View.hotspot_handlers.mousedown",
"MWidget.View.hotspot_handlers.cancelmousedown",
"MWidget.View.hotspot_handlers.mouseup",
id, 0, 0))
check(WindowDragHandler(self.name, id,
"MWidget.View.hotspot_handlers.dragmove",
"MWidget.View.hotspot_handlers.dragrelease",
0))
end
end
If I make the hotspots 2x2 instead, and change the for-loops to have a step of 2 instead of the default of 1, everything works fine. 2x2 isn't sufficient for my purposes, though, and it seems odd that 1x1 wouldn't work - it seems perfectly valid.
Another issue is that this takes a long time to execute, taking around 2 seconds on a 184x299 window. I think it wouldn't be such a bad idea to start using the 'flags' parameter to WindowAddHotspot, allowing you to modify the behavior of a single hotspot to send mouseover events for every mouse movement within the area, rather than just crossing into it from the outside. That way, I could just use one large hotspot instead of hundreds of tiny ones.
For reference, the reason I am doing this is because it provides the most convenient and intuitive way to create an abstraction layer over MUSHclient hotspots, allowing each widget in my framework to manage its own set of Hotspot objects (even if the widget is a child (contained within) of another widget). This solves the issue of how to percolate hotspot changes from subwidgets up to the visible frame, because my abstraction layer (implemented by the set of generic handlers you see in the code above) can use the information available to them to travel down the tree of subwidgets to locate the appropriate Hotspot to trigger.
Of course, if anyone has any other ideas I'm all ears, but I've been thinking about this for quite a while and I think it's the most viable way to go about it. After all, I think Win32 sends mouse-movement messages to its windows for every twitch of the mouse, doesn't it? So there is definitely precedent. [1]
[1] http://msdn.microsoft.com/en-us/library/ms645616(VS.85).aspx
EDIT: tl;dr summary, because I think I rambled a bit there:
* 1x1 hotspots seem to be malfunctioning, though I could just be doing something wrong.
* Fine-tuned mouse movement notification within a given hotspot would make a great flag for the unused 'flags' parameter in WindowAddHotspot.