Hotspot troubles

Posted by Wyd on Sun 24 May 2009 09:05 PM — 6 posts, 21,151 views.

#0
Hi,

I'm trying my hand at making miniwindows, but I'm having trouble implementing hotspots.

The following code is in a plugin (and passes when used inside check())

WindowAddHotspot("shipNav", "North",
171, 10, 213, 53,
"", -- mouseover
"", -- cancelmouseover
"", -- mousedown
"", -- cancelmousedown
"mouseup", -- mouseup
"Hrm", -- hint text if they hover over it
0, 0))

however it doesn't actually seem to do anything.

If I use WindowHotspotInfo("shipNav", "North", <number>) then it returns the correct infomation about the hotspot, however WindowHotspotList("ShipNav") returns nil.


Is there anything extra I need to do to attach the hotspot to the window and enable it?

Thanks
Australia Forum Administrator #1
Miniwindow names are case-sensitive so I would expect WindowHotspotList("ShipNav") to return nil.

What aspect isn't working? Is the hover text not appearing? Can you show more of the plugin please?
#2

if not nav then
  nav = {}
end

function mouseup(t, id)
	if id == "North" then
		Send("say turn north")
	end
end

--Create our nav window
if not nav.win then

	--Create our window
	WindowCreate("shipNav", 0, 0, 260, 300, 8, 1, ColourNameToRGB("black"))

	--Load our images
	WindowLoadImage ("shipNav", "moveCompassBackground", "C:/Program Files/MUSHclient/worlds/plugins/ShipNav/moveCompassBack.bmp")
	WindowLoadImage ("shipNav", "windBackground", "C:/Program Files/MUSHclient/worlds/plugins/ShipNav/windInfoBackground.bmp")


	--Draw stuff
	WindowDrawImage("shipNav", "moveCompassBackground", 128, 10,  255, 137, 2)
	check(WindowAddHotspot("shipNav", "North",
                   171, 10, 213, 53,
                   "", -- mouseover
                   "", -- cancelmouseover
                   "", -- mousedown
                   "", -- cancelmousedown
                   "mouseup", -- mouseup
                   "Hrm",    -- hint text if they hover over it
                   0, 0))


	--Small rectangle to show where the hotspot is while we get it working
	WindowRectOp ("shipNav", 1, 171, 10, 213, 53, ColourNameToRGB("orange"))
	WindowRectOp ("shipNav", 2, 0, 10,  122, 33, ColourNameToRGB("white"))
	WindowRectOp ("shipNav", 2, 0, 36,  122, 59, ColourNameToRGB("white"))
	WindowRectOp ("shipNav", 2, 0, 62,  122, 85, ColourNameToRGB("white"))
	WindowRectOp ("shipNav", 2, 0, 88,  122, 111, ColourNameToRGB("white"))
	WindowRectOp ("shipNav", 2, 0, 114,  122, 137, ColourNameToRGB("white"))
	WindowDrawImage("shipNav", "windBackground", 100, 145,  255, 295, 2)
	WindowRectOp ("shipNav", 2, 0, 145,  95, 190, ColourNameToRGB("purple"))
	WindowRectOp ("shipNav", 2, 0, 200,  95, 245, ColourNameToRGB("purple"))

	WindowRectOp ("shipNav", 2, 0, 255,  95, 295, ColourNameToRGB("purple"))

	WindowShow("shipNav", true)

	nav.win = true
end


The rest of the plugin has to do with the another miniwindow ("shipMap"), based of the mapping example Larkin posted elsewhere in the forum. The WindowRectOp() calls are just placeholders for parts I haven't implemented yet.

As for whats not working - tooltip isn't showing up, and the mouseup callback isn't been called. I tried to make a mouseover function, to test if it was picking up the moust moving into the area, but not getting anything from that, either



Amended on Mon 25 May 2009 03:54 AM by Wyd
Australia Forum Administrator #3
Hmm, we had this problem not so long ago. ;)

Here is your problem line:


--Create our window
	WindowCreate("shipNav", 0, 0, 260, 300, 8, 1, ColourNameToRGB("black"))


The problem is that the flags (1) are set to:


1 - Draw underneath. If set, the miniwindow is drawn beneath the scrolling text in the output window.


Thus the miniwindow is "underneath" the text and the test for hotspots is not done. This is because if you are underneath the text, you can click on the text to select it, not the hotspot.

Change the 1 to a 0 and it works.
Australia Forum Administrator #4
I'll amend the help to make this a bit clearer.
#5
Ah ha, thanks!

Thought it might be something small like that.