Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ Lua ➜ Hotspot Mouseover

Hotspot Mouseover

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Rene   (46 posts)  Bio
Date Tue 09 Oct 2018 11:55 PM (UTC)
Message
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!
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 10 Oct 2018 12:37 AM (UTC)
Message
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.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Rene   (46 posts)  Bio
Date Reply #2 on Wed 10 Oct 2018 05:25 AM (UTC)
Message
You would suggest adding Redraw() to the update_window function, or the mouseover() and cancelmouseover() ?

Thanks.
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 10 Oct 2018 06:39 AM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #4 on Wed 10 Oct 2018 06:43 AM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


14,021 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.