Author Topic: window.invalidate  (Read 4175 times)

0 Members and 1 Guest are viewing this topic.

Offline pianoman

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 426
  • Rating: +24/-0
  • ♪♫ ♪♫ ♪♫ ♪♫ ♪♫ ♪♫ ♪♫
    • View Profile
window.invalidate
« on: June 15, 2011, 06:34:04 pm »
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?
« Last Edit: June 15, 2011, 07:15:34 pm by pianoman »

Ashbad

  • Guest
Re: window.invalidate
« Reply #1 on: June 15, 2011, 07:15:52 pm »
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.

Offline pianoman

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 426
  • Rating: +24/-0
  • ♪♫ ♪♫ ♪♫ ♪♫ ♪♫ ♪♫ ♪♫
    • View Profile
Re: window.invalidate
« Reply #2 on: June 15, 2011, 07:16:40 pm »
Ok, that helps. Thanks!

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: window.invalidate
« Reply #3 on: June 16, 2011, 03:15:36 am »
The command above is actually incorrect, it should be:

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

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.

Offline hoffa

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 304
  • Rating: +131/-13
    • View Profile
Re: window.invalidate
« Reply #4 on: June 17, 2011, 10:02:33 am »
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.