Omnimaga

Calculator Community => TI Calculators => Lua => Topic started by: Munchor on June 15, 2011, 09:43:30 am

Title: on.up() Event
Post by: Munchor on June 15, 2011, 09:43:30 am
Inspired-Lua.org Wiki predicted that the function on.up() worked for when the moving the touchpad up.

I read it here: [lua]Category:Events[/lua]

So I decided to try it on real hardware with the following code:

Code: [Select]
draw_text = false

function on.paint()
    if draw_text then
        gc:drawString("Hello", 5, 5, "top")
    end
end

function on.up()
    draw_text = true
end

It didn't work, when I move the touchpad up (either by moving it or by pressing the key), the text "Hello" never appears.

Also, this didn't work either:

Code: [Select]
draw_text = false

function on.paint()
    if draw_text then
        gc:drawString("Hello", 5, 5, "top")
    end
end

function on.mouseUp()
    draw_text = true
    platform.window:invalidate()
end
Title: Re: on.up() Event
Post by: Jim Bauwens on June 15, 2011, 09:49:55 am
Code: [Select]
draw_text = false

function on.paint()
    if draw_text then
        gc:drawString("Hello", 5, 5, "top")
    end
end

function on.up()
    draw_text = true
end

Try adding platform.window:invalidate() in on.up()
Title: Re: on.up() Event
Post by: Munchor on June 15, 2011, 09:51:45 am
Thanks Jim, I forgot to refresh the window:

Code: [Select]
draw_text = false

function on.paint()
    if draw_text then
        gc:drawString("Hello", 5, 5, "top")
    end
end

function on.up()
    draw_text = true
    platform.window:invalidate()
end

It still didn't work, it seems like it has a different use, but I have no idea what.
Title: Re: on.up() Event
Post by: Jim Bauwens on June 15, 2011, 09:54:04 am
I just checked the official documentation, and it seems like there is no on.up. Maybe a type in the wiki. Try on.mouseUp .
Title: Re: on.up() Event
Post by: Munchor on June 15, 2011, 10:05:36 am
Ok, here are the results of my research.

Code: [Select]
draw_text = false

function on.paint(gc)
    if draw_text then
        gc:drawString("Hello", 5, 5, "top")
    end
end

function on.mouseUp()
    draw_text = true
    platform.window:invalidate()
end
Doesn't work

Code: [Select]
draw_text = false

function on.paint(gc)
    if draw_text then
        gc:drawString("Hello", 5, 5, "top")
    end
end

function on.grabUp()
    draw_text = true
    platform.window:invalidate()
end
If I grab and move up the touchpad, it works

Code: [Select]
draw_text = false

function on.paint(gc)
    if draw_text then
        gc:drawString("Hello", 5, 5, "top")
    end
end

function on.up()
    draw_text = true
    platform.window:invalidate()
end
on.up() doesn't work

Code: [Select]
draw_text = false

function on.paint(gc)
    if draw_text then
        gc:drawString("Hello", 5, 5, "top")
    end
end

function on.mouseMove()
    draw_text = true
    platform.window:invalidate()
end
Works whenever I move the mouse, any direction
Title: Re: on.up() Event
Post by: Ashbad on June 15, 2011, 10:13:21 am
Perhaps that last one returns a value corresponding to an actual key?
Title: Re: on.up() Event
Post by: Munchor on June 15, 2011, 10:16:43 am
Perhaps that last one returns a value corresponding to an actual key?

I ran this on my calculator and I (think) I tried all keys and possible movements.
Title: Re: on.up() Event
Post by: Jim Bauwens on June 15, 2011, 10:17:53 am
on.up doesn't exist (unless you define it and make a function to call it).
Title: Re: on.up() Event
Post by: Munchor on June 19, 2011, 12:53:21 pm
on.up doesn't exist (unless you define it and make a function to call it).

Hm, it is listed in the Wiki, maybe I'll remove it.
Title: Re: on.up() Event
Post by: BrownyTCat on June 25, 2011, 11:42:41 pm
Try this:
Code: [Select]
draw_text = false

function on.paint(gc)
    if draw_text then
        gc:drawString("Hello", 5, 5, "top")
    end
end

function on.arrowUp()
    draw_text = true
    platform.window:invalidate()
end

Or for all directions listed on screen:
Code: [Select]
draw_text = false
dir = none

function on.paint(gc)
    if draw_text then
        gc:drawString(dir, 5, 5, "top")
    end
end

function on.arrowUp()
dir = "up"
draw_text = true
end

function on.arrowDown()
dir = "down"
draw_text = true
end

function on.arrowLeft()
dir = "left"
draw_text = true
end

function on.arrowRight()
dir = "right"
draw_text = true
end
Title: Re: on.up() Event
Post by: Munchor on June 26, 2011, 06:32:43 am
BrownyTCat, what does that have to do with the objective of this post?
Title: Re: on.up() Event
Post by: BrownyTCat on June 26, 2011, 04:12:54 pm
BrownyTCat, what does that have to do with the objective of this post?
It has the code with the command that was asked for, with a version to show all the keys.
I forgot to add the invalidate() though. This won't run on a calc unless you use invalidate.
Title: Re: on.up() Event
Post by: Munchor on June 26, 2011, 04:20:47 pm
BrownyTCat, if you read the whole topic you can see we're talking about the touchpad.
Title: Re: on.up() Event
Post by: BrownyTCat on June 26, 2011, 04:24:01 pm
BrownyTCat, if you read the whole topic you can see we're talking about the touchpad.
I tested it with the touchpad emulation in Student Software and it worked. Of course otherwise there's no way, since the mouse has no actual definitions where it moves, only if it does. I don't own a touchpad so I have no idea if this works on real hardware.
Title: Re: on.up() Event
Post by: Levak on June 26, 2011, 04:24:13 pm
on.up doesn't exist (unless you define it and make a function to call it).

Hm, it is listed in the Wiki, maybe I'll remove it.

Well, in a way, we hadn't found it function yet... but it is listed in the OS itself as a built-in function already handled (examining phoenix.bin). So it works for something. Because we didn't had the time to test it, we temporary put this description. I will look for it for now.