Merge 7cfe7a0c5d
into a094675a49
This commit is contained in:
commit
e9817590ee
11 changed files with 30 additions and 6 deletions
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
0
README.md
Normal file → Executable file
0
README.md
Normal file → Executable file
0
button.lua
Normal file → Executable file
0
button.lua
Normal file → Executable file
0
checkbox.lua
Normal file → Executable file
0
checkbox.lua
Normal file → Executable file
36
core.lua
Normal file → Executable file
36
core.lua
Normal file → Executable file
|
@ -19,7 +19,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
|
||||
|
@ -43,6 +43,14 @@ function keyboard.pressed(key, code)
|
|||
keyboard.code = code
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
|
||||
function keyboard.tryGrab(id)
|
||||
if not context.keyfocus then
|
||||
context.keyfocus = id
|
||||
|
@ -51,14 +59,30 @@ 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.ctrl.up.code ~= -1 then
|
||||
if keyboard.key == keyboard.ctrl.up.key and keyboard.code == keyboard.ctrl.up.code then
|
||||
setKeyFocus(context.lastwidget)
|
||||
else
|
||||
setKeyFocus(nil)
|
||||
end
|
||||
keyboard.key = nil
|
||||
end
|
||||
else
|
||||
if keyboard.key == keyboard.ctrl.up.key then
|
||||
setKeyFocus(context.lastwidget)
|
||||
keyboard.key = nil
|
||||
end
|
||||
end
|
||||
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
|
||||
end
|
||||
context.lastwidget = id
|
||||
end
|
||||
|
||||
|
|
0
init.lua
Normal file → Executable file
0
init.lua
Normal file → Executable file
0
input.lua
Normal file → Executable file
0
input.lua
Normal file → Executable file
0
label.lua
Normal file → Executable file
0
label.lua
Normal file → Executable file
0
slider.lua
Normal file → Executable file
0
slider.lua
Normal file → Executable file
0
slider2d.lua
Normal file → Executable file
0
slider2d.lua
Normal file → Executable file
0
style-default.lua
Normal file → Executable file
0
style-default.lua
Normal file → Executable file
Loading…
Add table
Add a link
Reference in a new issue