Omnimaga
Calculator Community => TI Calculators => Lua => Topic started 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:
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:
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
-
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()
-
Thanks Jim, I forgot to refresh the window:
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.
-
I just checked the official documentation, and it seems like there is no on.up. Maybe a type in the wiki. Try on.mouseUp .
-
Ok, here are the results of my research.
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
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
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
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
-
Perhaps that last one returns a value corresponding to an actual key?
-
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.
-
on.up doesn't exist (unless you define it and make a function to call it).
-
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.
-
Try this:
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:
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
-
BrownyTCat, what does that have to do with the objective of this post?
-
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.
-
BrownyTCat, if you read the whole topic you can see we're talking about the touchpad.
-
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.
-
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.