Merge 5bc3f63440
into 44be6169e3
This commit is contained in:
commit
35ca58ed4e
2 changed files with 7 additions and 2 deletions
|
@ -30,7 +30,7 @@ local mouse = require(BASE .. 'mouse')
|
||||||
local keyboard = require(BASE .. 'keyboard')
|
local keyboard = require(BASE .. 'keyboard')
|
||||||
|
|
||||||
-- the widget
|
-- the widget
|
||||||
-- {text = text, pos = {x, y}, size={w, h}, widgetHit=widgetHit, draw=draw}
|
-- {text = text, hotkey="key", pos = {x, y}, size={w, h}, widgetHit=widgetHit, draw=draw}
|
||||||
return function(w)
|
return function(w)
|
||||||
assert(type(w) == "table" and w.text, "Invalid argument")
|
assert(type(w) == "table" and w.text, "Invalid argument")
|
||||||
|
|
||||||
|
@ -72,6 +72,6 @@ return function(w)
|
||||||
core.registerDraw(id, w.draw or core.style.Button,
|
core.registerDraw(id, w.draw or core.style.Button,
|
||||||
w.text, pos[1],pos[2], size[1],size[2])
|
w.text, pos[1],pos[2], size[1],size[2])
|
||||||
|
|
||||||
return mouse.releasedOn(id) or keyboard.pressedOn(id, 'return')
|
return mouse.releasedOn(id) or keyboard.pressedOn(id, 'return') or keyboard.pressedHotkey(w.hotkey)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,10 @@ local function pressedOn(id, k)
|
||||||
return (k or 'return') == key and hasFocus(id) and k
|
return (k or 'return') == key and hasFocus(id) and k
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function pressedHotkey(hotkey)
|
||||||
|
return hotkey and ( key == hotkey )
|
||||||
|
end
|
||||||
|
|
||||||
local function beginFrame()
|
local function beginFrame()
|
||||||
-- for future use?
|
-- for future use?
|
||||||
end
|
end
|
||||||
|
@ -99,6 +103,7 @@ return setmetatable({
|
||||||
hasFocus = hasFocus,
|
hasFocus = hasFocus,
|
||||||
makeCyclable = makeCyclable,
|
makeCyclable = makeCyclable,
|
||||||
pressedOn = pressedOn,
|
pressedOn = pressedOn,
|
||||||
|
pressedHotkey = pressedHotkey,
|
||||||
|
|
||||||
disable = disable,
|
disable = disable,
|
||||||
enable = clearFocus,
|
enable = clearFocus,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue