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
|