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 ➜ Trace function

Trace function

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 Mon 11 Jul 2011 05:46 AM (UTC)
Message
I'm getting start to learn about miniwindows...than I have a question about this, the code posted below

Why there is no change without turn on the trace function?
is there anything missing? Thanks.

--------------------------------------
<aliases>
<alias
match="win_cre"
enabled="y"
send_to="12"
sequence="100"
>
<send>win = "test_" .. GetPluginID ()

WindowCreate (win, 0, 0, 200, 200, miniwin.pos_center_all, 0, ColourNameToRGB("white")) -- create window


-- Grid
for i = 1, math.max (WindowInfo (win, 3), WindowInfo (win, 4)) / 10 do
WindowLine (win, i * 10, 0, i * 10, WindowInfo (win, 4), 0xC0C0C0, miniwin.pen_solid, 1)
WindowLine (win, 0, i * 10, WindowInfo (win, 3), i * 10, 0xC0C0C0, miniwin.pen_solid, 1)
end -- for

--[button hot spot]
WindowRectOp (win, miniwin.rect_fill, 50, 50, 100, 100,
ColourNameToRGB("green")) -- filled

function mouseover (flags, hotspot_id)
WindowRectOp (win, miniwin.rect_fill, 50, 50, 100, 100,
ColourNameToRGB("red")) -- filled
return 0 -- needed for some languages
end -- mouseover

function cancelmouseover (flags, hotspot_id)
WindowRectOp (win, miniwin.rect_fill, 50, 50, 100, 100,
ColourNameToRGB("green")) -- filled
return 0 -- needed for some languages
end -- cancelmouseover

function mousedown (flags, hotspot_id)
WindowRectOp (win, miniwin.rect_fill, 50, 50, 100, 100,
ColourNameToRGB("black")) -- filled
return 0 -- needed for some languages
end -- mousedown

function cancelmousedown (flags, hotspot_id)
WindowRectOp (win, miniwin.rect_fill, 50, 50, 100, 100,
ColourNameToRGB("green")) -- filled
return 0 -- needed for some languages
end -- cancelmousdown

function mouseup (flags, hotspot_id)
WindowRectOp (win, miniwin.rect_fill, 50, 50, 100, 100,
ColourNameToRGB("red")) -- filled
return 0 -- needed for some languages
end -- mouseup

WindowAddHotspot(win, "hs1",
50, 50, 100, 100, -- rectangle
"mouseover",
"cancelmouseover",
"mousedown",
"cancelmousedown",
"mouseup",
"Click here to be healed", -- tooltip text
miniwin.cursor_hand, 0) -- hand cursor

-- [Display the window]
WindowShow (win , true)</send>
</alias>
</aliases>
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 11 Jul 2011 06:19 AM (UTC)

Amended on Mon 11 Jul 2011 06:21 AM (UTC) by Nick Gammon

Message
Changes to window contents are not drawn until the window is redrawn. To force this to happen you need to call the Redraw function. Like this:


<aliases>
  <alias
   match="win_cre"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

win = "test_" .. GetPluginID ()

WindowCreate (win, 0, 0, 200, 200, miniwin.pos_center_all, 0, ColourNameToRGB("white"))  -- create window


-- Grid
  for i = 1, math.max (WindowInfo (win, 3), WindowInfo (win, 4)) / 10 do
    WindowLine (win, i * 10, 0, i * 10, WindowInfo (win, 4), 0xC0C0C0, miniwin.pen_solid, 1)
    WindowLine (win, 0, i * 10, WindowInfo (win, 3), i * 10, 0xC0C0C0, miniwin.pen_solid, 1)
  end -- for

--[button hot spot]
WindowRectOp (win, miniwin.rect_fill, 50, 50, 100, 100, 
              ColourNameToRGB("green"))  -- filled

function mouseover (flags, hotspot_id)
  WindowRectOp (win, miniwin.rect_fill, 50, 50, 100, 100, 
              ColourNameToRGB("red"))  -- filled
  Redraw ()
end -- mouseover

function cancelmouseover (flags, hotspot_id)
 WindowRectOp (win, miniwin.rect_fill, 50, 50, 100, 100, 
              ColourNameToRGB("green"))  -- filled
  Redraw ()
end -- cancelmouseover

function mousedown (flags, hotspot_id)
 WindowRectOp (win, miniwin.rect_fill, 50, 50, 100, 100, 
              ColourNameToRGB("black"))  -- filled
  Redraw ()
end -- mousedown

function cancelmousedown (flags, hotspot_id)
 WindowRectOp (win, miniwin.rect_fill, 50, 50, 100, 100, 
              ColourNameToRGB("green"))  -- filled
  Redraw ()
end -- cancelmousdown

function mouseup (flags, hotspot_id)
  WindowRectOp (win, miniwin.rect_fill, 50, 50, 100, 100, 
              ColourNameToRGB("red"))  -- filled
  Redraw ()
end -- mouseup
  
WindowAddHotspot(win, "hs1",  
                 50, 50, 100, 100,   -- rectangle
                 "mouseover", 
                 "cancelmouseover", 
                 "mousedown",
                 "cancelmousedown", 
                 "mouseup", 
                 "Click here to be healed",  -- tooltip text
                 miniwin.cursor_hand, 0)  -- hand cursor

-- [Display the window]
WindowShow (win , true)

</send>
  </alias>
</aliases>


With Trace on, the window is being constantly redrawn, that is why it seemed to work.

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 Tkl1129   Hong Kong  (43 posts)  Bio
Date Reply #2 on Mon 11 Jul 2011 07:15 AM (UTC)
Message
oh, Nice.. :D thanks~
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.


16,041 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.