Hotspot Mouseover

Posted by Rene on Tue 09 Oct 2018 11:55 PM — 5 posts, 20,609 views.

#0
So I've created a hotspot with a mouseover option, yet for some reason if I am not receiving text from the MUD, just connected idly it does not update the Miniwindow, what am I doing wrong?

Here is my hotspot:

	WindowAddHotspot(win, "close", window_width - WindowTextWidth(win, "f", "X") - 5 - 2, 1, window_width - 3 + 2, font_height + 1,   --rectangle
				"mouseover",   -- MouseOver
				"cancelmouseover",   -- CancelMouseOver
                "mousedown",
                 "cancelmousedown", 
                 "mouseup", 
                 "",  -- tooltip text
                 miniwin.cursor_arrow, 0) 


It changes the colour of the hotspot with this:

	if mouse_over == true then
		WindowRectOp(win, miniwin.rect_fill, window_width - WindowTextWidth(win, "f", "X") - 5 - 2, 1, window_width - 3 + 2, font_height + 1, ColourNameToRGB("red"), ColourNameToRGB("black"))
		WindowText (win, "f", "X", window_width - WindowTextWidth(win, "f", "X") - 4, 1, 0, 0,	ColourNameToRGB("white"), false) -- not Unicode
	else
		WindowText (win, "f", "X", window_width - WindowTextWidth(win, "f", "X") - 4, 1, 0, 0,	ColourNameToRGB("black"), false) -- not Unicode
		WindowRectOp(win, miniwin.rect_frame, window_width - WindowTextWidth(win, "f", "X") - 5 - 2, 1, window_width - 3 + 2, font_height + 1, ColourNameToRGB("gray"), ColourNameToRGB("black"))
	end


And here is the mouseover and cancelmouseover functions:

mouse_over = false
function mouseover(flags, hotspot_id)
	if hotspot_id == "close" then
		mouse_over = true
		update_window()
	end
end
function cancelmouseover(flags, hotspot_id)
	if hotspot_id ~= "close" then
		mouse_over = false
		update_window()
	end
end


I feel I am missing something simple, it works fine if I add some note to the MUD or the MUD sends text, but otherwise it does not update.

Thanks!
Australia Forum Administrator #1
Rene said:

... for some reason if I am not receiving text from the MUD, just connected idly it does not update the Miniwindow


Try calling Redraw after changing the window:


Redraw ()


Template:function=Redraw
Redraw

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

#2
You would suggest adding Redraw() to the update_window function, or the mouseover() and cancelmouseover() ?

Thanks.
Australia Forum Administrator #3
The function that does the WindowText. The window is not automatically redrawn, calling Redraw() does that. It is also redrawn when new text arrives, which seems to be what you are saying.
Australia Forum Administrator #4
The reason for this is that miniwindows are really off-screen bitmaps, which are updated when you call the various documented functions (text, rectangles, circles etc.).

They are only copied into their designated spot on the main window when a window update occurs, which is usually when new text arrives, however you can force it with Redraw().

If each drawing function also did a Redraw() then that would slow them down, for no real advantage, as you normally want the new miniwindow to be shown when it is completed, not when it is partially completed.