[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Miniwindows
. . -> [Subject]  Redraw of Text

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Redraw of Text
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Thu 25 Aug 2011 09:56 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Tkl1129   Hong Kong  (43 posts)  [Biography] bio
Date Thu 25 Aug 2011 08:39 AM (UTC)  quote  ]
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~
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Thu 25 Aug 2011 07:51 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Tkl1129   Hong Kong  (43 posts)  [Biography] bio
Date Thu 25 Aug 2011 05:10 AM (UTC)  quote  ]
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"?
[Go to top] top

Posted by Tkl1129   Hong Kong  (43 posts)  [Biography] bio
Date Thu 25 Aug 2011 04:00 AM (UTC)  quote  ]
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 
[Go to top] top

Posted by Fiendish   USA  (848 posts)  [Biography] bio   Global Moderator
Date Tue 23 Aug 2011 07:28 PM (UTC)  quote  ]
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

http://aardwolfclientpackage.googlecode.com/
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Tue 23 Aug 2011 11:12 AM (UTC)  quote  ]
Message
I don't see where you change the button colour.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Tkl1129   Hong Kong  (43 posts)  [Biography] bio
Date Tue 23 Aug 2011 09:17 AM (UTC)  quote  ]
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



[Go to top] 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.


1,199 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]