diff options
author | mkosler <marekkpie@gmail.com> | 2012-02-21 16:05:03 -0600 |
---|---|---|
committer | mkosler <marekkpie@gmail.com> | 2012-02-21 16:05:03 -0600 |
commit | 7cfe7a0c5d119e5bd499475b7fc0544eec8368c7 (patch) | |
tree | 290711315b56e0bf8f43d910649ba4e45ed48b21 | |
parent | 3a414b52e2c94b866ae57876be6880a74f5f8ac8 (diff) | |
download | Quickie-7cfe7a0c5d119e5bd499475b7fc0544eec8368c7.tar.gz Quickie-7cfe7a0c5d119e5bd499475b7fc0544eec8368c7.tar.bz2 Quickie-7cfe7a0c5d119e5bd499475b7fc0544eec8368c7.tar.xz Quickie-7cfe7a0c5d119e5bd499475b7fc0544eec8368c7.zip |
Fixed the borked select functionality. Also improved the user interface
for core.keyboard.controls.
-rwxr-xr-x | core.lua | 36 |
1 files changed, 25 insertions, 11 deletions
@@ -43,9 +43,11 @@ function keyboard.pressed(key, code) keyboard.code = code end -function keyboard.controls(up, down) - keyboard.ctrl.up = up - keyboard.ctrl.down = down +function keyboard.controls(up, down, upCode, downCode) + keyboard.ctrl.up.key = up + keyboard.ctrl.down.key = down + keyboard.ctrl.up.code = upCode or -1 + keyboard.ctrl.down.code = downCode or -1 end @@ -58,16 +60,28 @@ end local function makeTabable(id) keyboard.tryGrab(id) if hasKeyFocus(id) then - if keyboard.key ~= nil then - print(string.format("Keyboard values: %s, %d | Set control values: (down) %s, %d (up) %s, %d", keyboard.key, keyboard.code, keyboard.ctrl.down.key, keyboard.ctrl.down.code, keyboard.ctrl.up.key, keyboard.ctrl.up.code)) + if keyboard.ctrl.up.code ~= -1 then + if keyboard.key == keyboard.ctrl.up.key and keyboard.code == keyboard.ctrl.up.code then + setKeyFocus(context.lastwidget) + keyboard.key = nil + end + else + if keyboard.key == keyboard.ctrl.up.key then + setKeyFocus(context.lastwidget) + keyboard.key = nil + end end - if keyboard.key == keyboard.ctrl.up.key and keyboard.code == keyboard.ctrl.up.code then - setKeyFocus(context.lastwidget) - elseif keyboard.key == keyboard.ctrl.down.key and keyboard.code == keyboard.ctrl.down.code then - setKeyFocus(nil) + if keyboard.ctrl.down.code ~= -1 then + if keyboard.key == keyboard.ctrl.down.key and keyboard.code == keyboard.ctrl.down.code then + setKeyFocus(nil) + keyboard.key = nil + end + else + if keyboard.key == keyboard.ctrl.down.key then + setKeyFocus(nil) + keyboard.key = nil + end end - keyboard.key = nil - keyboard.code = -1 end context.lastwidget = id end |