Add gui.core.(disable|clear)KeyFocus
This commit is contained in:
parent
370c10c787
commit
465aaf1885
2 changed files with 32 additions and 21 deletions
|
@ -17,6 +17,11 @@ Quickie is an [immediate mode gui][IMGUI] library for [LÖVE][LOVE]
|
||||||
-- checkboxes have only a `checked' status
|
-- checkboxes have only a `checked' status
|
||||||
local checkbox = {checked = false}
|
local checkbox = {checked = false}
|
||||||
|
|
||||||
|
function love.load()
|
||||||
|
-- disable tabbing through the widgets
|
||||||
|
gui.core.disableKeyFocus()
|
||||||
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
-- widgets are defined by simply calling them. usually a widget returns true if
|
-- widgets are defined by simply calling them. usually a widget returns true if
|
||||||
-- if its value changed or if it was activated (click on button, ...)
|
-- if its value changed or if it was activated (click on button, ...)
|
||||||
|
@ -37,8 +42,8 @@ Quickie is an [immediate mode gui][IMGUI] library for [LÖVE][LOVE]
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.keypressed(key,code)
|
function love.keypressed(key,code)
|
||||||
-- forward keyboard events to the gui. If you don't want widget tabbing and
|
-- forward keyboard events to the gui. If you don't want keyboard support
|
||||||
-- input widgets, skip this line
|
-- skip this line
|
||||||
gui.core.keyboard.pressed(key, code)
|
gui.core.keyboard.pressed(key, code)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
44
core.lua
44
core.lua
|
@ -17,6 +17,9 @@ local function isActive(id) return context.active == id end
|
||||||
local function setKeyFocus(id) context.keyfocus = id end
|
local function setKeyFocus(id) context.keyfocus = id end
|
||||||
local function hasKeyFocus(id) return context.keyfocus == id end
|
local function hasKeyFocus(id) return context.keyfocus == id end
|
||||||
|
|
||||||
|
local function disableKeyFocus() return setKeyFocus{} end
|
||||||
|
local function clearKeyFocus() return setKeyFocus(nil) end
|
||||||
|
|
||||||
-- input
|
-- input
|
||||||
local mouse = {x = 0, y = 0, down = false}
|
local mouse = {x = 0, y = 0, down = false}
|
||||||
local keyboard = {key = nil, code = -1}
|
local keyboard = {key = nil, code = -1}
|
||||||
|
@ -50,7 +53,7 @@ end
|
||||||
|
|
||||||
function keyboard.tryGrab(id)
|
function keyboard.tryGrab(id)
|
||||||
if not context.keyfocus then
|
if not context.keyfocus then
|
||||||
context.keyfocus = id
|
setKeyFocus(id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -136,25 +139,28 @@ local function draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
mouse = mouse,
|
mouse = mouse,
|
||||||
keyboard = keyboard,
|
keyboard = keyboard,
|
||||||
|
|
||||||
generateID = generateID,
|
generateID = generateID,
|
||||||
setHot = setHot,
|
setHot = setHot,
|
||||||
setActive = setActive,
|
setActive = setActive,
|
||||||
setKeyFocus = setKeyFocus,
|
setKeyFocus = setKeyFocus,
|
||||||
isHot = isHot,
|
isHot = isHot,
|
||||||
isActive = isActive,
|
isActive = isActive,
|
||||||
hasKeyFocus = hasKeyFocus,
|
hasKeyFocus = hasKeyFocus,
|
||||||
makeCyclable = makeCyclable,
|
|
||||||
|
|
||||||
style = require((...):match("(.-)[^%.]+$") .. '.style-default'),
|
disableKeyFocus = disableKeyFocus,
|
||||||
color = color,
|
clearKeyFocus = clearKeyFocus,
|
||||||
registerDraw = registerDraw,
|
makeCyclable = makeCyclable,
|
||||||
draw = draw,
|
|
||||||
|
|
||||||
strictAnd = strictAnd,
|
style = require((...):match("(.-)[^%.]+$") .. '.style-default'),
|
||||||
strictOr = strictOr,
|
color = color,
|
||||||
save_pack = save_pack,
|
registerDraw = registerDraw,
|
||||||
save_unpack = save_unpack,
|
draw = draw,
|
||||||
|
|
||||||
|
strictAnd = strictAnd,
|
||||||
|
strictOr = strictOr,
|
||||||
|
save_pack = save_pack,
|
||||||
|
save_unpack = save_unpack,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue