Fixed the borked select functionality. Also improved the user interface
for core.keyboard.controls.
This commit is contained in:
parent
3a414b52e2
commit
7cfe7a0c5d
1 changed files with 25 additions and 11 deletions
36
core.lua
36
core.lua
|
@ -43,9 +43,11 @@ function keyboard.pressed(key, code)
|
||||||
keyboard.code = code
|
keyboard.code = code
|
||||||
end
|
end
|
||||||
|
|
||||||
function keyboard.controls(up, down)
|
function keyboard.controls(up, down, upCode, downCode)
|
||||||
keyboard.ctrl.up = up
|
keyboard.ctrl.up.key = up
|
||||||
keyboard.ctrl.down = down
|
keyboard.ctrl.down.key = down
|
||||||
|
keyboard.ctrl.up.code = upCode or -1
|
||||||
|
keyboard.ctrl.down.code = downCode or -1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,16 +60,28 @@ end
|
||||||
local function makeTabable(id)
|
local function makeTabable(id)
|
||||||
keyboard.tryGrab(id)
|
keyboard.tryGrab(id)
|
||||||
if hasKeyFocus(id) then
|
if hasKeyFocus(id) then
|
||||||
if keyboard.key ~= nil then
|
if keyboard.ctrl.up.code ~= -1 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.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
|
end
|
||||||
if keyboard.key == keyboard.ctrl.up.key and keyboard.code == keyboard.ctrl.up.code then
|
if keyboard.ctrl.down.code ~= -1 then
|
||||||
setKeyFocus(context.lastwidget)
|
if keyboard.key == keyboard.ctrl.down.key and keyboard.code == keyboard.ctrl.down.code then
|
||||||
elseif keyboard.key == keyboard.ctrl.down.key and keyboard.code == keyboard.ctrl.down.code then
|
setKeyFocus(nil)
|
||||||
setKeyFocus(nil)
|
keyboard.key = nil
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if keyboard.key == keyboard.ctrl.down.key then
|
||||||
|
setKeyFocus(nil)
|
||||||
|
keyboard.key = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
keyboard.key = nil
|
|
||||||
keyboard.code = -1
|
|
||||||
end
|
end
|
||||||
context.lastwidget = id
|
context.lastwidget = id
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue