Author Topic: on.up() Event  (Read 5862 times)

0 Members and 1 Guest are viewing this topic.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
on.up() Event
« 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
« Last Edit: June 15, 2011, 09:57:52 am by Scout »

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: on.up() Event
« Reply #1 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()

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: on.up() Event
« Reply #2 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.

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: on.up() Event
« Reply #3 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 .

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: on.up() Event
« Reply #4 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

Ashbad

  • Guest
Re: on.up() Event
« Reply #5 on: June 15, 2011, 10:13:21 am »
Perhaps that last one returns a value corresponding to an actual key?
« Last Edit: June 15, 2011, 10:14:02 am by Ashbad »

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: on.up() Event
« Reply #6 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.

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: on.up() Event
« Reply #7 on: June 15, 2011, 10:17:53 am »
on.up doesn't exist (unless you define it and make a function to call it).

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: on.up() Event
« Reply #8 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.

Offline BrownyTCat

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 420
  • Rating: +37/-8
    • View Profile
Re: on.up() Event
« Reply #9 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
« Last Edit: June 25, 2011, 11:46:20 pm by BrownyTCat »

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: on.up() Event
« Reply #10 on: June 26, 2011, 06:32:43 am »
BrownyTCat, what does that have to do with the objective of this post?

Offline BrownyTCat

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 420
  • Rating: +37/-8
    • View Profile
Re: on.up() Event
« Reply #11 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.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: on.up() Event
« Reply #12 on: June 26, 2011, 04:20:47 pm »
BrownyTCat, if you read the whole topic you can see we're talking about the touchpad.

Offline BrownyTCat

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 420
  • Rating: +37/-8
    • View Profile
Re: on.up() Event
« Reply #13 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.

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: on.up() Event
« Reply #14 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.
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua