Advertisement
tupperkion

UiUtils Documentation

Jan 30th, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.45 KB | None | 0 0
  1.  
  2. Info
  3. ====
  4.  
  5. Table format is as follows:
  6.  
  7. a = {
  8.     button1 = {
  9.         type = "button",
  10.         xy = {10, 20},
  11.         hw = {50, 100},
  12.         click = myClickFuncton, -- called as myClickFunction(id)
  13.         textColor = colors.white,
  14.         activeTextColor = colors.white,
  15.         color = colors.red,
  16.         activeColor = colors.green,
  17.         toggle = true,
  18.         active = false,
  19.         text = "Button",
  20.         data = myData
  21.     },
  22.     label1 = {
  23.         type = "label",
  24.         xy = {10, 20},
  25.         hw = {50, 100},
  26.         color = colors.blue,
  27.         textColor = colors.white,
  28.         text = "This is some text",
  29.         data = myData
  30.     },
  31.     point1 = {
  32.         type = "point",
  33.         yx = {10, 20},
  34.         color = colors
  35.     line1 = {
  36.         type = "line",
  37.         direction = "horizontal", -- "horizontal", "vertical", "diagonalLeft", "diagonalRight"
  38.         xy = {10, 20},
  39.         length = 5,
  40.         color = colors.blue,
  41.         textColor = colors.white,
  42.         char = " ", -- must have length 1
  43.         data = myData
  44.     box1 = {
  45.         type = "box",
  46.         xy = {10, 20},
  47.         hw = {50, 100},
  48.         color = colors.blue,
  49.         textColor = colors.white,
  50.         char = " ", -- must have length 1
  51.         data = myData
  52.     },
  53.     frame1 = {
  54.         type = "frame",
  55.         xy = {10, 20},
  56.         hw = {50, 100},
  57.         color = colors.red,
  58.         textColor = colors.white,
  59.         char = " ", -- must have length 1
  60.         data = myData
  61.     },
  62.     pattern1 = {
  63.         type = "pattern",
  64.         xy = {10, 20},
  65.         hw = {50, 100},
  66.         iterator = myIteratorFunction, -- will be called as myIteratorFunction(currX, currY, id)
  67.             -- should return "{color = color, textColor = textColor, char = char}"
  68.         data = myData
  69.     },
  70.     textField1 = {
  71.         type = "textField",
  72.         xy = {10, 20},
  73.         hw = {50, 100},
  74.         offsetX = 0,
  75.         offsetY = 0,
  76.         color = colors.black,
  77.         textColor = colors.white,
  78.         text = "This is some auto-wrapped text.\nCool, right?",
  79.         data = myData
  80.     },
  81.     textBox1 = {
  82.         type = "textBox",
  83.         xy = {10, 20},
  84.         length = 10,
  85.         text = "This is some default text",
  86.         cursorPos = 0,
  87.         color = colors.black,
  88.         textColor = colors.white,
  89.         isAtEnd = true -- will automatically set cursorPos to #text
  90.     },
  91.     textEdit1 = {
  92.         type = "textEdit",
  93.         xy = {10, 20},
  94.         hw = {50, 100},
  95.         cursorXY = {1, 1} ...
  96.     }  
  97. }
  98.  
  99. Notes:
  100.  
  101.  
  102. When a native UI system element updates, all custom table elements on the screen will be cleared.
  103.  
  104. Use labels instead of print/write to write text on the screen.
  105.  
  106. All "xy" values dictate the top left corner of where the element will be drawn (except for diagonal lines).
  107.  
  108. All "xy" values of lines dictate the start of the line. Horizontal lines start on the left, vertical/diagonal lines start at the top.
  109.  
  110. Custom table UI elements will NOT effect the native UI system.
  111.  
  112. The native UI table CANNOT be iterated (it will behave as if it is empty).
  113.  
  114. The native UI table will automatically update when changed.
  115.  
  116. The "data" values will not be touched by any components of the API, can be used for your own purposes.
  117.  
  118. If a textbox is focused, runEvent will never call back mouse clicks as it will be caught to blur the textbox.
  119.  
  120. Events will NEVER be caught by the api. For any interaction to occur, you MUST run the even through uiutils.runEvent().
  121.  
  122. This api will NOT rely on os.pullEventRaw(), and you DO NOT EVER have to run terminate events through os.pullEventRaw().
  123.  
  124.  
  125. The following applies ONLY to elements using the custom table system (drawCustomTable()):
  126.  
  127.  
  128. All functions will be called with original table instead of the id (because there is no id).
  129.  
  130. You will be responsible for updating and redrawing all elements when they update.
  131.  
  132. On buttons, the "toggle" value will have no effect.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement