Calculator Community > Lua

window.invalidate

(1/1)

pianoman:
Hi!
I was just wondering, what exactly does window.invalidate do, and how would you use it?

Edit: I looked it up on the inspired-lua site, but I'm still slightly confused. Do you have to define it like in the example in the Linking Events tutorial?

Ashbad:
Basically, it renders the current screen.  With no parameters, it refreshes the whole screen, but it accepts these:

Window.invalidate(top x pos, top y pos, width, height)

So you can specify the area of the screen being updated.

pianoman:
Ok, that helps. Thanks!

Jim Bauwens:
The command above is actually incorrect, it should be:


--- Code: (Lua) ---platform.window:invalidate(top x pos, top y pos, width, height)

--- End code ---

What is will do it set a flag (a flag is like a little note that your write) that the screen needs to be redrawn. A little later the flag get read, and it checks how much needs to be redrawn. Then it clears the area and calls the function on.paint which contains your code to draw stuff on the screen.

hoffa:
Actually it's not a very practical function, but it's the only way to refresh the screen. It eventually calls on.paint(), meaning it can get quite frustrating if your program needs a lot of refreshes at specific moments.

Navigation

[0] Message Index

Go to full version