joebodo

ui.example.lua

Mar 11th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. package.path =
  2.   "/sys/modules/?.lua;/sys/modules/?/init.lua;" .. package.path
  3.  
  4. local UI = require('opus.ui')
  5.  
  6. local page = UI.Page {
  7.   button = UI.Button {
  8.     text = 'quit',
  9.     ex = -2, y = 2,
  10.     width = 6,
  11.   },
  12.   grid = UI.Grid {
  13.     y = 4,
  14.     columns = {
  15.       { heading = 'col1', key = 'k', width = 6, textColor = colors.cyan },
  16.       { heading = 'col2', key = 'v' },
  17.     },
  18.     values = {
  19.       { k = 'key1', v = 'value1' },
  20.       { k = 'key2', v = 'value2' },
  21.       { k = 'key3', v = 'value3' },
  22.       { k = 'key5', v = 'value5' },
  23.       { k = 'key4', v = 'value4' },
  24.     },
  25.     sortColumn = 'k',
  26.   },
  27.   textEntry = UI.TextEntry {
  28.     x = 2, y = 2,
  29.     limit = 16,
  30.     width = 32,
  31.     shadowText = 'example entry',
  32.   }
  33. }
  34.  
  35. function page:eventHandler(event)
  36.   if event.type == 'button_press' then
  37.     UI:exitPullEvents()
  38.   end
  39.   return UI.Page.eventHandler(self, event)
  40. end
  41.  
  42. UI:setPage(page)
  43. UI:pullEvents()
Add Comment
Please, Sign In to add comment