PicoPicoGameEngine

Quick Links

Text Object

pptext

Subclass of ppsprite.

.new()

text = pptext.new()
text_array = pptext.new(n)
text : pptext object

n : number

text_array : object

:frameRect()

text:frameRect( x,y,width,height)
text:frameRect( {x,y,width,height})
text:frameRect(frame)
result = text:frameRect()
text : pptext object

x : number

y : number

width : number

height : number

frame : rectangle object

result : pprect object

m=pptext.new()
w=ppscreen:size().width
m:frameRect(16,16,w-32,300)
for i=0,30 do
  m:add("LIST "..i)
end

function start()
  ppgraph:fill(
    m:frameRect(),ppgraph.blue)
  v=ppscreen:viewport()
  ppscreen:viewport(
    m:frameRect())
  m:idle()
  m:draw()
  ppscreen:viewport(v)
end

:contentsRect()

text:contentsRect(rect)
result = text:contentsRect()
text : pptext object

rect : rectangle object

result : pprect object

:isDragging()

result = text:isDragging()
text : pptext object

result : boolean

  • true
  • false

:idle()

text:idle()
text : pptext object

:clear()

text:clear()
text : pptext object

:text()

text:text(text)
text : pptext object

:lineHeight()

text:lineHeight(lineHeight)
lineHeight = text:lineHeight()
text : pptext object

lineHeight : number

:cellRect()

result = text:cellRect(cell_index)
text : pptext object

cell_index : number

result : rectangle object

m=pptext.new()
m:frameRect(16,16,100,100)
m:add("HELLO WOLRD 1")
m:add("HELLO")
  
function start()
  ppgraph:fill(
    m:frameRect(),ppgraph.blue)
  v=ppscreen:viewport()
  ppscreen:viewport(m:frameRect())
  m:idle()
  m:draw()
  ppscreen:viewport(v)
  
  ppgraph:box(
    m:cellRect(1),ppgraph.red)
  ppgraph:box(
    m:cellRect(2),ppgraph.red)
  
end

:cellString()

strings = text:cellString(cell_index)
text : pptext object

cell_index : number

strings : string object array

m=pptext.new()
m:frameRect(16,16,100,100)
m:add("HELLO WOLRD 1")
m:add("HELLO WOLRD 2")
  
function start()
  ppgraph:fill(
    m:frameRect(),ppgraph.blue)
  v=ppscreen:viewport()
  ppscreen:viewport(m:frameRect())
  m:idle()
  m:draw()
  ppscreen:viewport(v)
  ppgraph:locate(132,16)
  local l=m:cellString(1)
  for k,v in pairs(l) do
    ppgraph:print(k..":"..v)
    ppgraph:move(0,16)
  end
end

:autoScroll()

text:autoScroll(flag)
flag = text:autoScroll()
text : pptext object

flag : boolean

  • true
  • false

:autoCenter()

text:autoCenter(flag)
flag = text:autoCenter()
text : pptext object

flag : boolean

  • true
  • false

:cellCount()

result = text:cellCount()
text : pptext object

result : number

:hideCell()

text:hideCell(flag)
flag = text:hideCell()
text : pptext object

flag : boolean

  • true
  • false

:select()

text:select(select_cell_index)
text : pptext object

select_cell_index : object

m=pptext.new()
m:frameRect(
  ppscreen:size())
m:add("HELLO WOLRD 1")
m:add("HELLO WORLD 2")
m:add("HELLO WORLD 3")
m:add("HELLO WORLD 4")
m:add("HELLO WORLD 5")
m:selectable(true)
-- Select 2,4,5 lines
m:select({2,4,5})

function start()
  ppgraph:fill(
    m:frameRect(),
    ppgraph.blue)
  ppscreen:viewport(
    m:frameRect())
  m:idle()
  m:draw()
  ppscreen:viewport(
    ppscreen:size())
end

:selectedColor()

text:selectedColor(color)
color = text:selectedColor()
text : pptext object

color : color object

:selectable()

text:selectable(flag)
flag = text:selectable()
text : pptext object

flag : boolean

  • true
  • false

:multiselectable()

text:multiselectable(flag)
flag = text:multiselectable()
text : pptext object

flag : boolean

  • true
  • false

:emptyselection()

text:emptyselection(flag)
flag = text:emptyselection()
text : pptext object

flag : boolean

  • true
  • false

:column()

text:column(column)
column = text:column()
text : pptext object

column : number

m=pptext.new()
m:frameRect(
  ppscreen:size())
for i=0,30 do
  m:add("LIST "..i)
end
m:column(2)

function start()
  ppgraph:fill(
    m:frameRect(),
    ppgraph.blue)
  ppscreen:viewport(
    m:frameRect())
  m:idle()
  m:draw()
  ppscreen:viewport(
    ppscreen:size())
end

:speed()

text:speed(speed)
speed = text:speed()
text : pptext object

speed : number

:add()

text:add(string)
text : pptext object

string : string

:append()

text:append(string)
text : pptext object

string : string

:done()

done = text:done()
text : pptext object

done : boolean

  • true
  • false

:cursorPosition()

pos = text:cursorPosition()
text : pptext object

pos : point object

:margin()

text:margin( top, right, bottom, left)
text:margin( {top, right, bottom, left})
text:margin({top=top, right=right, bottom=bottom, left=left})
text : pptext object

top : number

right : number

bottom : number

left : number

:lastSelect()

cell_index = text:lastSelect()
text : pptext object

cell_index : number