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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Miniwindows ➜ Redraw of Text

Redraw of Text

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


Posted by Tkl1129   Hong Kong  (43 posts)  Bio
Date Tue 23 Aug 2011 09:17 AM (UTC)
Message
the mini window, I wanna make a button which "mouseover" will change button color and text color...
however, I only can change the button color but the word txt was disappear...any suggestion? Thanks.


Original:
WindowText (login, "f2", Char[Char_list]["name"] .. "(" ..  Char[Char_list]["id"] .. ")",
					space_w + 5, b_start + 4, space_w + b_width, b_start + b_height,
					ColourNameToRGB ("blue"), false)

Mouseover:
function mouseover (flags,hotspot_id)
	if hotspot_id == 1 then
		WindowText (login, "f2", Char[Char_list[hotspot_id]]["name"] .. "(" ..  Char[Char_list[hotspot_id]]["id"] .. ")",
					space_w + 5, b_start + 4, space_w + b_width, b_start + b_height,
					ColourNameToRGB ("red"), false)
		WindowText (login, "f2", "Lv: " .. "500",
					space_w + (b_width/3*2) + 5, b_start + 4, space_w + b_width, b_start + b_height,
					ColourNameToRGB ("red"), false)	
Redraw ()
end
CancelMouseover:

function cancelmouseover (flags,hotspot_id)
	if hotspot_id == 1 then
		WindowText (login, "f2", Char[Char_list[hotspot_id]]["name"] .. "(" ..  Char[Char_list[hotspot_id]]["id"] .. ")",
					space_w + 5, b_start + 4, space_w + b_width, b_start + b_height,
					ColourNameToRGB ("white"), false)
		WindowText (login, "f2", "Lv: " .. "500",
					space_w + (b_width/3*2) + 5, b_start + 4, space_w + b_width, b_start + b_height,
					ColourNameToRGB ("white"), false)			
		print(type(hotspot_id),hotspot_id)
	else
		print(type(hotspot_id),hotspot_id)
	end --if
	Repaint ()
end -- cancelmouseover



Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 23 Aug 2011 11:12 AM (UTC)
Message
I don't see where you change the button colour.

- Nick Gammon

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

Posted by Fiendish   USA  (2,558 posts)  Bio   Global Moderator
Date Reply #2 on Tue 23 Aug 2011 07:28 PM (UTC)
Message
Also, before pasting any code into the forum, you need to make sure you're escaping out the forum codes. Right now your code is all italicized because the forum saw [i]. MUSHclient can do this for you automatically by going to Edit->Convert Clipboard Forum Codes

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Tkl1129   Hong Kong  (43 posts)  Bio
Date Reply #3 on Thu 25 Aug 2011 04:00 AM (UTC)
Message
ok sorry...make it simple.

I don't know my approach is correct or not.

1. Want to make a login miniwindow, which have many button, some words describe the Character info on the button
2. when mouseover the button, the color of button change, words color change too
3. click to execute cmds ( This simple)
4. when Cancelmouseover, the the color change back

-------------------------------------------------------

The problem I meet, was when the mouseover, the color of button was change, but the word disappear, and while cancelmouseover, the color change back, but the word still not appear. that's my question, and the code are as below, thanks.
---------------------------------------------------------

require ("db_login")

--[[Window Info]]

local char = table.getn(Char_list)
local space_w = 40
local space_h = 15
local b_start = 40
local b_height = 20
local b_width = 180
local window_w = space_w * 2 + b_width
local window_h = b_start + (b_height + space_h) * char

--[[Window Create]]
login = "Login" .. GetPluginID ()  -- get a unique name, ensure not empty if outside plugin

WindowCreate (login, 0, 0, window_w, window_h, miniwin.pos_center_all, 4, ColourNameToRGB("black"))  -- create window
WindowFont (login, "f", "細明體", 8, false, false, false, false) -- define font
WindowFont (login, "f2", "細明體", 6, false, false, false, false) -- define font

--[[Frame]]
WindowCircleOp (login, miniwin.circle_round_rectangle, -- round rectangle
                5, 5, window_w - 5, window_h - 5,	            -- Left, Top, Right, Bottom
                ColourNameToRGB("y"), miniwin.pen_solid, 1.5,   -- pen width 2
                ColourNameToRGB("darkred"), miniwin.brush_solid,  -- brush
                10,   -- width of the ellipse used to draw the rounded corner
                10)   -- height of the ellipse used to draw the rounded corner
-- [[Tittle]]
WindowPolygon (login, "20,23,28,23,24,28",
                        ColourNameToRGB("yellow"), miniwin.pen_solid, 0.5,   -- pen (solid, width 1)
                        ColourNameToRGB("white"), miniwin.brush_solid,    -- brush (solid)
                        true,    -- fill
                        false)   -- alternate fill
WindowText (login, "f", 
                "Login : ",   -- text
                40, 20, 0, 0,        -- rectangle
                ColourNameToRGB ("yellow"), -- colour
                false)              -- not Unicode

-- [[buttons]]
function mouseup (flags, hotspot_id)
	print ("Login" .. " char " .. hotspot_id)
end -- mouseup
function mouseover (flags,hotspot_id)
	if hotspot_id == 1 then
		WindowRectOp (login, miniwin.rect_fill, space_w, b_start, space_w + b_width, b_start + b_height, ColourNameToRGB("darkgray"))  -- filled
		WindowRectOp (login, miniwin.rect_frame, space_w, b_start, space_w + b_width, b_start + b_height, ColourNameToRGB("yellow"))  -- filled
	else
		WindowRectOp (login, miniwin.rect_fill, space_w, b_start + (b_height + space_h) * (hotspot_id-1), space_w + b_width, (b_start + b_height) + (b_height + space_h) * (hotspot_id-1) , ColourNameToRGB("darkgray"))  -- filled
		WindowRectOp (login, miniwin.rect_frame, space_w, b_start + (b_height + space_h) * (hotspot_id-1), space_w + b_width, (b_start + b_height) + (b_height + space_h) * (hotspot_id-1) , ColourNameToRGB("yellow"))  -- filled

	end --if
	Redraw ()
end -- mouseover
function cancelmouseover (flags,hotspot_id)
	if hotspot_id == 1 then
		WindowRectOp (login, miniwin.rect_fill, space_w, b_start, space_w + b_width, b_start + b_height, ColourNameToRGB("darkred"))  -- filled
		WindowRectOp (login, miniwin.rect_frame, space_w, b_start, space_w + b_width, b_start + b_height, ColourNameToRGB("white"))  -- filled
	else
		WindowRectOp (login, miniwin.rect_fill, space_w, b_start + (b_height + space_h) * (hotspot_id-1), space_w + b_width, (b_start + b_height) + (b_height + space_h) * (hotspot_id-1) , ColourNameToRGB("darkred"))  -- filled
		WindowRectOp (login, miniwin.rect_frame, space_w, b_start + (b_height + space_h) * (hotspot_id-1), space_w + b_width, (b_start + b_height) + (b_height + space_h) * (hotspot_id-1) , ColourNameToRGB("white"))  -- filled
	end --if
	Redraw ()
end -- cancelmouseover


for i=1,char do
	if i==1 then
		WindowRectOp (login, miniwin.rect_frame, space_w, b_start, space_w + b_width, b_start + b_height,ColourNameToRGB("white"))
		WindowAddHotspot(login,i,  
                 space_w, b_start, space_w + b_width, b_start + b_height,
                 "mouseover", "cancelmouseover", "mousedown", "cancelmousedown", "mouseup", "Character" .. " " .. i,
                 miniwin.cursor_hand, 0)  -- hand cursor

	else
		WindowRectOp (login, miniwin.rect_frame, space_w, b_start + (b_height + space_h) * (i-1), space_w + b_width, (b_start + b_height) + (b_height + space_h) * (i-1), ColourNameToRGB("white"))
		WindowAddHotspot(login,i,  
                  space_w, b_start + (b_height + space_h) * (i-1), space_w + b_width, (b_start + b_height) + (b_height + space_h) * (i-1) , 
                 "mouseover", "cancelmouseover", "mousedown", "cancelmousedown", "mouseup", "Character" .. " " .. i,
                 miniwin.cursor_hand, 0)  -- hand cursor
	end --if
end--for
				

--[[print window]]
WindowShow (login, 1)  -- show it 
Top

Posted by Tkl1129   Hong Kong  (43 posts)  Bio
Date Reply #4 on Thu 25 Aug 2011 05:10 AM (UTC)
Message

function mouseover (flags, hotspot_id)
 print(hotspot_id)
end --function


I just add this code inside, I found the reason why the text why cannot redraw, but why the mouseup can callout the "hotspot_id" be the right id but mouseover and cancelmouseover only return "nil"?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #5 on Thu 25 Aug 2011 07:51 AM (UTC)
Message
Hotspot IDs are strings, not numbers, so this will never be true:


	if hotspot_id == 1 then


- Nick Gammon

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

Posted by Tkl1129   Hong Kong  (43 posts)  Bio
Date Reply #6 on Thu 25 Aug 2011 08:39 AM (UTC)
Message
Oh, you had remind me...its work now


local x = tonumber("" .. hotspot_id)


the local var "x" become a number in "1"
The login miniwindow work now..thanks~
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #7 on Thu 25 Aug 2011 09:56 AM (UTC)
Message
Tkl1129 said:

Oh, you had remind me...its work now


local x = tonumber("" .. hotspot_id)



Or even:



local x = tonumber(hotspot_id)



- 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.


25,710 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.