Difference between revisions of "on.charIn"

From Inspired-Lua Wiki
Jump to navigation Jump to search
(Created page with " Category:Events")
 
m
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
'''on.charIn''' is an event that catches the user's keypresses on the keyboard.
  
 +
Here's an example on how to use it :
  
 +
<syntaxhighlight>
 +
input = ""  -- the string that will contain the user's typed message
 +
 +
function on.paint(gc)
 +
    gc:drawString(input,5,5,"top")  -- drawing the current string on screen
 +
end
 +
 +
function on.charIn(char)
 +
    input = input..char  -- appending
 +
    platform.window:invalidate()  -- refreshing the screen
 +
end
 +
 +
</syntaxhighlight>
 +
 +
You can here find a more detailed tutorial on how to use it to create a text input function :
 +
http://inspired-lua.org/index.php/2011/12/how-to-have-a-nice-little-input-function-in-lua/
  
 
[[Category:Events]]
 
[[Category:Events]]

Latest revision as of 15:51, 17 December 2013

on.charIn is an event that catches the user's keypresses on the keyboard.

Here's an example on how to use it :

 input = ""   -- the string that will contain the user's typed message

 function on.paint(gc)
     gc:drawString(input,5,5,"top")  -- drawing the current string on screen
 end

 function on.charIn(char)
     input = input..char   -- appending
     platform.window:invalidate()   -- refreshing the screen
 end

You can here find a more detailed tutorial on how to use it to create a text input function : http://inspired-lua.org/index.php/2011/12/how-to-have-a-nice-little-input-function-in-lua/