Just thought of a screen for a level editor:
editor = {
tiles = { my, tile, objects, selected=1 }
tools = {
selected=1,
{
name="tile picker",draw=function(self)
set_screen_bright(); set_font_small()
screen.move(0,10); screen.text_left(tile.name)
end
},{
name="place",draw=function(self, xy)
set_screen_dim(); set_font_small()
screen.move(0,10); screen.text_left(tile.name)
draw_cursor(xy[1],xy[2])
end
},{
name="erase",draw=function(self,xy)
set_screen_dim(); set_font_small()
screen.move(0,10); screen.text_left(tile.name)
draw_cursor(xy[1],xy[2])
end
},
xy = {1,1},
draw = function(self)
local tool = self.tools[self.tools.selected]
local tile = self.tiles[self.tiles.selected]
set_font_small(); set_screen_dim()
screen.move(0,10); screen.text_center(tool.name)
tool:draw(self.xy)
end,
event = function(self,bool)
local tool = self.tools[self.tools.selected]
local tile = self.tiles[self.tiles.selected]
local x,y = self.xy[1],self.xy[2]
if tool = "place" then
-- game.screen[3] is the world
if bool then game.screen[3].tiles[x][y] = tile end
elseif tool = "erase" then
if bool then game.screen[3].tiles[x][y] = nil end
end
end
}
Use your imagination for the key and encoder funcs but they basically just involve firing off events and scrolling whatever happens to be in focus 
This reveals a pattern for chaining draw function lookups combined with state. This is probably not great for performance in the long run, but eventually these calls can be optimized by composing these functions in clever ways.
Not sure if any of this is a good idea, but it’s a fun framework for really flexible UIs.