Omnimaga

Calculator Community => TI Calculators => Lua => Topic started by: Spyro543 on June 05, 2011, 03:46:38 pm

Title: Codes for touchpad, arrow keys, select button, other keys?
Post by: Spyro543 on June 05, 2011, 03:46:38 pm
I know this code is correct for the up arrow
Code: (up arrow) [Select]
function on.arrowUp
       --what to do goes here
end

Do I just replace the Up in on.arrowUp with whatever direction? and also: Does anyone here know what the Lua codes for detecting what happens with the touchpad, select button, and other keys?
Title: Re: Codes for touchpad, arrow keys, select button, other keys?
Post by: apcalc on June 05, 2011, 06:31:24 pm
Here is a list of all of the keys that can be "controlled" with Lua (notice on.charLn for non-arrow key characters)

Also, I think you might need a "()" after function.arrowUp (making it read "function.arrowUp()")
Title: Re: Codes for touchpad, arrow keys, select button, other keys?
Post by: Levak on June 05, 2011, 06:44:27 pm
http://www.inspired-lua.org/
Title: Re: Codes for touchpad, arrow keys, select button, other keys?
Post by: Spyro543 on June 05, 2011, 06:46:18 pm
Here is a list of all of the keys that can be "controlled" with Lua

Where is the list?
Title: Re: Codes for touchpad, arrow keys, select button, other keys?
Post by: Levak on June 05, 2011, 06:48:02 pm
Here is a list of all of the keys that can be "controlled" with Lua

Where is the list?

All the "basic questions" like this one are answered when looking at http://www.inspired-lua.org/  and http://wiki.inspired-lua.org/
Title: Re: Codes for touchpad, arrow keys, select button, other keys?
Post by: Spyro543 on June 05, 2011, 06:50:19 pm
This: http://wiki.inspired-lua.org/Category:Events

So on.down(), on.up(), on.left(), and on.right() are for touchpad motions. Right?
Title: Re: Codes for touchpad, arrow keys, select button, other keys?
Post by: Levak on June 05, 2011, 06:51:37 pm
This: http://wiki.inspired-lua.org/Category:Events

So on.down(), on.up(), on.left(), and on.right() are for touchpad motions. Right?

wrong.
EDIT : oops sorry, wrong one. Yeah, so "probably". You can test.
EDIT2 : hum, there is neither "on.right()" nor "on.left", so I think it is for something else.


There is no specification between TouchPad and ClickPad, since the TouchPad invokes a mouse.
Title: Re: Codes for touchpad, arrow keys, select button, other keys?
Post by: Spyro543 on June 05, 2011, 06:54:26 pm
So it would go like this:

The mouse is already controlled by the touchpad, no need to program this.
on.mouseDown is when the mouse is clicked, it reports that it was clicked and at what coordinates it was clicked at. What is the syntax for on.mouseDown?
Title: Re: Codes for touchpad, arrow keys, select button, other keys?
Post by: Levak on June 05, 2011, 06:56:34 pm
So it would go like this:

The mouse is already controlled by the touchpad, no need to program this.
on.mouseDown is when the mouse is clicked, it reports that it was clicked and at what coordinates it was clicked at. What is the syntax for on.mouseDown?

This question is part of the "Starting in Lua" tutoring part. I guess you should look at it before beginning a project (we haven't finished the EN part ... sorry)


To answer quickly : on.mouseDown(x, y)
Title: Re: Codes for touchpad, arrow keys, select button, other keys?
Post by: Spyro543 on June 05, 2011, 07:00:32 pm
So on.mouseDown(n, m) will save the X coordinate to var n, Y coordinate to var m?

Or does it have to store to vars x and y?
Title: Re: Codes for touchpad, arrow keys, select button, other keys?
Post by: Levak on June 05, 2011, 07:02:03 pm
So on.mouseDown(n, m) will save the X coordinate to var n, Y coordinate to var m?

Or does it have to store to vars x and y?

Again ... you work in an evenmential environnement. Those questions are answered, please take the time to read everything.
http://www.inspired-lua.org/category/tutorials/starting-in-lua/
Title: Re: Codes for touchpad, arrow keys, select button, other keys?
Post by: apcalc on June 05, 2011, 07:02:07 pm
Sorry, I forgot to post the link in my first post. :(
Title: Re: Codes for touchpad, arrow keys, select button, other keys?
Post by: Spyro543 on June 05, 2011, 07:04:58 pm
So on.mouseDown(n, m) will save the X coordinate to var n, Y coordinate to var m?

Or does it have to store to vars x and y?

Again ... you work in an evenmential environnement. Those questions are answered, please take the time to read everything.
http://www.inspired-lua.org/category/tutorials/starting-in-lua/

May I have a simple and direct answer please? I've read tutorials, but only 2 in english.
Title: Re: Codes for touchpad, arrow keys, select button, other keys?
Post by: Levak on June 06, 2011, 04:10:34 am
Code: [Select]
function on.paint(gc)
 if mX and mY then
  gc:setPen("sansserif", "r", 18)
  gc:drawString("You pressed at ("..mx..", "..my..") coordinates", 0, 0, "top")
 end
end

function on.mouseDown(x, y)
 mX, mY = x, y
end
Title: Re: Codes for touchpad, arrow keys, select button, other keys?
Post by: Jim Bauwens on June 06, 2011, 04:28:27 am
Levak, you forgot to invalidate the screen when mouseDown is triggered.

Code: (Lua) [Select]
function on.mouseDown(x, y)
 mX, mY = x, y
 platform.window:invalidate()
end
Title: Re: Codes for touchpad, arrow keys, select button, other keys?
Post by: Levak on June 06, 2011, 04:35:27 am
Yeah, thanks, I was eating my breakfast, I hadn't got the mind to that. x)
Title: Re: Codes for touchpad, arrow keys, select button, other keys?
Post by: DJ Omnimaga on June 06, 2011, 03:06:59 pm
Levak, when people ask questions on Omnimaga, you are not allowed to tell them to just JFGI or search an entire website. You direct them to the answer or answer them on the forums. If you don't want to do that then you don't help. This is rude to the new members who are starting out. At Omnimaga, "RTFM"-type posts are not tolerated unless someone asks how to install a specific game and the instructions are all clearly available in the readme.
Title: Re: Codes for touchpad, arrow keys, select button, other keys?
Post by: Levak on June 06, 2011, 06:08:15 pm
/me has to change his mind ... done

Though, it wasn't an "entire" website, since we have only 4 tutorials that helped many people (I didn't expected so much). Thus I think he should read those, because they weren't very long, before starting and asking those question. I really like the RTFM method, since it really helps people searching by themselves. It is evident that, when there is no answer, or the answer is really complicated, we help this person, since he will search for many hours and doesn't find it afterall and come back again.

I'm sure we can come between those two ideas =)
Title: Re: Codes for touchpad, arrow keys, select button, other keys?
Post by: DJ Omnimaga on June 06, 2011, 06:32:25 pm
Ah ok, I thought a lot of the stuff from Hackspire was already included. However, what I don't like about the RTFM thing is that it scares away new members and programmers, as it feels to them they're not given a chance. Eventually they give up or leave in some cases, and that happened before on some other boards. It even reached the point where some people who saw it happening on other boards and that it was encouraged by staff decided to migrate here because it felt friendlier. As a result, that site almost lost its entire userbase within half a year and is now pretty much a ghost town.

Also it was one of the first time that person asks questions anyay. When someone repeatdely ask simple questions that got answered many times here, then I'm in for a RTFM (as long as it's polite).