構文 | editText( タイトル[,初期文字列セットフラグ] ) 戻り値: 入力文字, 入力結果コード |
説明 | 文字入力ダイアログを表示します。 |
引数 | タイトル: ダイアログに表示する文字です。 初期文字列セットフラグ : 入力時に初期文字列をセットするかどうかのフラグ 0:無し 1:有り |
戻り値 | 入力文字列(最大240バイト) 入力結果コード 0:Cancel 1:OK |
------------------------------------------
-- 文字入力ダイアログを表示するサンプル editText_sample.lua
------------------------------------------
function main()
local txtInput
local ref
canvas.drawCls(color(255,255,255))
canvas.drawText("文字入力ダイアログを表示するサンプル", 0, 0, 24, color(0,0,0))
canvas.drawText("画面タッチで文字入力ダイアログを表示します。", 0, 30, 24, color(0,0,0))
touch(3)
txtInput, ref = editText("テキストを入力")
if(ref == 0) then
canvas.drawText("キャンセルされました。", 0, 60, 24, color(255,0,0))
elseif(ref == 1 and txtInput == "") then
canvas.drawText("入力されていません。", 0, 60, 24, color(255,0,0))
else
canvas.drawText("入力されたのは、 " .. txtInput .. " です。", 0, 60, 24, color(255,0,0))
end
canvas.drawText("画面タッチで終了します。", 0, 100, 24, color(0,0,0))
touch(3)
end
main()