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 ➜ Trouble with "erasing" text

Trouble with "erasing" text

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


Posted by Boris_Bee   (5 posts)  Bio
Date Fri 12 Oct 2012 03:12 AM (UTC)
Message
I have 1 miniwindow that I am attempted to write text to. I have two functions that draw text to the window, and one of them is working fine. It draws text, and when it's time to change the text it draws a rectangle to "erase" the text, then writes more text on top. The second function does the same thing except this one draws text to the right of the first text area. The problem lies here, as the text is written fine, but the rectangle it draws to cover up the text is draw on top of the text. The text is never seen. I'v fiddled with this for quite a while and I just cannot get it working. Why does my first function work correctly and the second function does not?

function draw_conc (name, line, wildcards, styles)

local left = 0

	for _, v in ipairs (styles) do

		local width = WindowTextWidth (win, "f", v.text)
		local right = left + width
      		WindowRectOp (win, miniwin.rect_fill, left, 0, 344, 0, v.backcolour)  -- draw background
	   	WindowText(win, "f", v.text, left, 3, 0, 0, v.textcolour, false)
		left = left + width
	end -- for each style run
	WindowShow(win, true)
end

function draw_aura (name, line, wildcards, styles)

local left = 344 + 20

	for _, v in ipairs (styles) do

		local width = WindowTextWidth (win, "f", v.text)
		local right = left + width
      		WindowRectOp (win, miniwin.rect_fill, left, 0, 344, 0, ColourNameToRGB("black"))  -- draw background
	   	WindowText(win, "f", v.text, left, 3, 0, 0, v.textcolour, false)
		left = left + width
	end -- for each style run
	WindowShow(win, true)
end
Top

Posted by Fiendish   USA  (2,555 posts)  Bio   Global Moderator
Date Reply #1 on Fri 12 Oct 2012 03:22 AM (UTC)
Message
FYI, WindowText returns the number of pixels the text took horizontally. By adding that to the "Left" parameter, you can draw some more text to the right of what was just written, so you don't need to keep calling the Width function like you do.

Quote:
Why does my first function work correctly and the second function does not?

"344"

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

Posted by Boris_Bee   (5 posts)  Bio
Date Reply #2 on Sat 13 Oct 2012 10:05 AM (UTC)
Message
Thanks that solved it, although I'm still not quite sure why heh.
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.


13,799 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.