parent
10e79ca5c8
commit
6960a80eaa
3 changed files with 31 additions and 6 deletions
17
README.md
17
README.md
|
@ -23,7 +23,13 @@ More info and code is over at [readthedocs](http://suit.readthedocs.org/en/lates
|
|||
local suit = require 'suit'
|
||||
|
||||
-- storage for text input
|
||||
local input = {text = ""}
|
||||
local input = {text = "", candidate_text = {text="", start=0, length=0}}
|
||||
|
||||
-- make love use font which support CJK text
|
||||
function love.load()
|
||||
local font = love.graphics.newFont("NotoSansHans-Regular.otf", 20)
|
||||
love.graphics.setFont(font)
|
||||
end
|
||||
|
||||
-- all the UI is defined in love.update or functions that are called from here
|
||||
function love.update(dt)
|
||||
|
@ -33,7 +39,7 @@ function love.update(dt)
|
|||
|
||||
-- put an input widget at the layout origin, with a cell size of 200 by 30 pixels
|
||||
suit.Input(input, suit.layout:row(200,30))
|
||||
|
||||
|
||||
-- put a label that displays the text below the first cell
|
||||
-- the cell size is the same as the last one (200x30 px)
|
||||
-- the label text will be aligned to the left
|
||||
|
@ -41,7 +47,7 @@ function love.update(dt)
|
|||
|
||||
-- put an empty cell that has the same size as the last cell (200x30 px)
|
||||
suit.layout:row()
|
||||
|
||||
|
||||
-- put a button of size 200x30 px in the cell below
|
||||
-- if the button is pressed, quit the game
|
||||
if suit.Button("Close", suit.layout:row()).hit then
|
||||
|
@ -54,6 +60,11 @@ function love.draw()
|
|||
suit.draw()
|
||||
end
|
||||
|
||||
function love.textedited(text, start, length)
|
||||
-- for IME input
|
||||
input.candidate_text = {text = text, start= start, length = length}
|
||||
end
|
||||
|
||||
function love.textinput(t)
|
||||
-- forward text input to SUIT
|
||||
suit.textinput(t)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue