hotspots' function for buttons

Posted by Tkl1129 on Tue 12 Jul 2011 02:22 AM — 4 posts, 19,407 views.

Hong Kong #0
I'm do testing on button + hotspot, and I've got problem.
I use mouseover + cancelmouse over be the test tools.
if the mouseover function use "hotspot_id", it will apply to all hotspot, but what if I only want it apply to specific hotspot? am I able to make 2 function, 1 for "hs1" and 1 for "hs2", but seems it don't work, or make 2 different function name recall to that hotspot? I just want a simply way to write it, thanks.
----------------------------------------------------------
Case:
--Mouseover button 1, color "maroon" -> "red"
--Mouseover button 2, color "maroon" -> "blue"

--button 1
WindowRectOp (win, miniwin.rect_fill, 50, 50, 100, 100,
ColourNameToRGB("maroon")) -- filled
--button 2
WindowRectOp (win, miniwin.rect_fill, 50, 150, 100, 200,
ColourNameToRGB("maroon")) -- filled

--mouseover function
function mouseover (flags, hs1)
WindowRectOp (win, miniwin.rect_fill, 50, 50, 100, 100,
ColourNameToRGB("red")) -- filled
Redraw ()
end -- mouseover
function mouseover (flags, hs2)
WindowRectOp (win, miniwin.rect_fill, 50, 150, 100, 200,
ColourNameToRGB("blue")) -- filled
Redraw ()
end -- mouseover

--Cancelmouse function
function cancelmouseover (flags, hs1)
WindowRectOp (win, miniwin.rect_fill, 50, 50, 100, 100,
ColourNameToRGB("maroon")) -- filled
Redraw ()
end -- cancelmouseover
function cancelmouseover (flags, hs2)
WindowRectOp (win, miniwin.rect_fill, 50, 150, 100, 200,
ColourNameToRGB("maroon")) -- filled
Redraw ()
end -- cancelmouseover


--hotspot for button 1
WindowAddHotspot(win, "hs1",
50, 50, 100, 100, -- rectangle
"mouseover",
"cancelmouseover",
"mousedown",
"cancelmousedown",
"mouseup",
"Drag it!", -- tooltip text
miniwin.cursor_hand, 0) -- hand cursor

--hotspot for button 2
WindowAddHotspot(win, "hs2",
50, 150, 100, 200, -- rectangle
"mouseover",
"cancelmouseover",
"mousedown",
"cancelmousedown",
"mouseup",
"Drag it! 2", -- tooltip text
miniwin.cursor_hand, 0) -- hand cursor

--------------------------------------------------------
Australia Forum Administrator #1
Template:codetag
To make your code more readable please use [code] tags as described here.


Use different function names, eg.


WindowAddHotspot(win, "hs2",
50, 150, 100, 200, -- rectangle
"mouseover_hs2",
"cancelmouseover_hs2",
"mousedown_hs2",
"cancelmousedown_hs2",
"mouseup_hs2",
"Drag it! 2", -- tooltip text
miniwin.cursor_hand, 0) -- hand cursor


Hong Kong #2

-- I will remember this, thanks.
Australia Forum Administrator #3
Template:function=WindowHotspotInfo
WindowHotspotInfo

The documentation for the WindowHotspotInfo script function is available online. It is also in the MUSHclient help file.



That could save you keying in the coordinates of each hotspot many times. Given the hotspot ID (eg "hs2") you can find out where it is, thus allowing you to fill in the correct rectangle.