aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Richter <vrld@vrld.org>2013-03-24 19:59:27 +0100
committerMatthias Richter <vrld@vrld.org>2013-03-24 19:59:27 +0100
commit43265a44ca25b17225eeeae8d377d29fb7c7ee45 (patch)
treee3430bc80cfded604f6ad6f1d61a9a2d6655997b
parentebe0ce2ac009869df58a8afead08461849b4d487 (diff)
downloadQuickie-43265a44ca25b17225eeeae8d377d29fb7c7ee45.tar.gz
Quickie-43265a44ca25b17225eeeae8d377d29fb7c7ee45.tar.bz2
Quickie-43265a44ca25b17225eeeae8d377d29fb7c7ee45.tar.xz
Quickie-43265a44ca25b17225eeeae8d377d29fb7c7ee45.zip
Fix #7: Pressing return crashes Input.
Add arguments to call of keyboard.pressed() in input.lua. Add sanity check to keyboard.pressed().
-rw-r--r--input.lua2
-rw-r--r--keyboard.lua6
2 files changed, 6 insertions, 2 deletions
diff --git a/input.lua b/input.lua
index 17c372f..dd5e3aa 100644
--- a/input.lua
+++ b/input.lua
@@ -63,7 +63,7 @@ return function(w)
-- info
elseif keyboard.key == 'return' then
keyboard.clearFocus()
- keyboard.pressed()
+ keyboard.pressed('', -1)
elseif keyboard.code >= 32 and keyboard.code < 127 then
local left = w.info.text:sub(1,w.info.cursor)
local right = w.info.text:sub(w.info.cursor+1)
diff --git a/keyboard.lua b/keyboard.lua
index f6ae2e1..50323ff 100644
--- a/keyboard.lua
+++ b/keyboard.lua
@@ -34,7 +34,11 @@ local cycle = {
next = {key = 'tab'},
}
-local function pressed(...) key, code = ... end
+local function pressed(...)
+ key, code = ...
+ assert(type(key) == 'string', 'Invalid argument `key`. Expected string, got ' .. type(key))
+ assert(type(code) == 'number', 'Invalid argument `code`. Expected number, got ' .. type(code))
+end
local function setFocus(id) focus = id end
local function disable() focus = NO_WIDGET end
local function clearFocus() focus = nil end