Skip to content

Commit

Permalink
Added ability to change controls for tabbable with hacky LOVE quirks.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkosler committed Feb 21, 2012
1 parent 6926699 commit 5411455
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 4 deletions.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified button.lua
100644 → 100755
Empty file.
Empty file modified checkbox.lua
100644 → 100755
Empty file.
18 changes: 14 additions & 4 deletions core.lua
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ local function hasKeyFocus(id) return context.keyfocus == id end

-- input
local mouse = {x = 0, y = 0, down = false}
local keyboard = {key = nil, code = -1}
local keyboard = {key = nil, code = -1, ctrl = {down = {key = "tab", code = 9}, up = {key = "tab", code = 0}}}

function mouse.inRect(x,y,w,h)
return mouse.x >= x and mouse.x <= x+w and mouse.y >= y and mouse.y <= y+h
Expand All @@ -42,6 +42,12 @@ function keyboard.pressed(key, code)
keyboard.code = code
end

function keyboard.controls(ctrl)
keyboard.ctrl.up = ctrl.up
keyboard.ctrl.down = ctrl.down
end


function keyboard.tryGrab(id)
if not context.keyfocus then
context.keyfocus = id
Expand All @@ -50,13 +56,17 @@ end

local function makeTabable(id)
keyboard.tryGrab(id)
if hasKeyFocus(id) and keyboard.key == 'tab' then
if love.keyboard.isDown('rshift', 'lshift') then
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))
end
if keyboard.key == keyboard.ctrl.up.key and keyboard.code == keyboard.ctrl.up.code then
setKeyFocus(context.lastwidget)
else
elseif keyboard.key == keyboard.ctrl.down.key and keyboard.code == keyboard.ctrl.down.code then
setKeyFocus(nil)
end
keyboard.key = nil
keyboard.code = -1
end
context.lastwidget = id
end
Expand Down
Empty file modified init.lua
100644 → 100755
Empty file.
Empty file modified input.lua
100644 → 100755
Empty file.
Empty file modified label.lua
100644 → 100755
Empty file.
Empty file modified slider.lua
100644 → 100755
Empty file.
Empty file modified slider2d.lua
100644 → 100755
Empty file.
Empty file modified style-default.lua
100644 → 100755
Empty file.

0 comments on commit 5411455

Please sign in to comment.