97abf037b8
Follows the submodule: on_touch_down and friends become onTouchDown, the last snake_case left in the surface now that handlers are table fields rather than globals. main.lua declares SlateApp, this card's contract with its apps, and every app composes what it fills -- PaintApp is SlateApp plus TouchHandlers, Home is SlateApp alone -- which is also the only static record of the features an app needs.
39 lines
725 B
Lua
39 lines
725 B
Lua
local ui = require "ui"
|
|
local keyboard = require "keyboard"
|
|
|
|
---@class KeyboardApp : SlateApp
|
|
local M = {}
|
|
local valueLabel
|
|
local shown = "type something"
|
|
|
|
local function show(prefix, value)
|
|
shown = value == "" and "type something" or prefix .. value
|
|
ui.setText(valueLabel, shown)
|
|
end
|
|
|
|
function M.init()
|
|
log.info "keyboard test ready"
|
|
end
|
|
|
|
function M.node()
|
|
valueLabel = ui.text(shown, { w = "fill" })
|
|
return ui.box {
|
|
w = "fill",
|
|
h = "fill",
|
|
pad = 8,
|
|
gap = 5,
|
|
valueLabel,
|
|
keyboard.new {
|
|
max_length = 40,
|
|
on_change = function(value)
|
|
show("value: ", value)
|
|
end,
|
|
on_submit = function(value)
|
|
show("submitted: ", value)
|
|
end,
|
|
},
|
|
}
|
|
end
|
|
|
|
return M
|