mod: inputbox finished

pull/2/merge
Qingping Hou 13 years ago
parent 3bc71354ed
commit 29a9996fb2

@ -2,7 +2,7 @@ require "rendertext"
require "keys" require "keys"
require "graphics" require "graphics"
require "fontchooser" require "fontchooser"
require "fileseacher" require "filesearcher"
require "inputbox" require "inputbox"
FileChooser = { FileChooser = {
@ -188,7 +188,8 @@ function FileChooser:choose(ypos, height)
end end
pagedirty = true pagedirty = true
elseif ev.code == KEY_S then elseif ev.code == KEY_S then
InputBox:input(height-100, 100) input = InputBox:input(height-100, 100)
print(input)
--FileSeacher:init() --FileSeacher:init()
--FileSeacher:choose(0, height) --FileSeacher:choose(0, height)
pagedirty = true pagedirty = true

@ -21,6 +21,7 @@ InputBox = {
input_bg = 1, input_bg = 1,
input_string = "",
-- state buffer -- state buffer
dirs = nil, dirs = nil,
files = nil, files = nil,
@ -48,6 +49,7 @@ function InputBox:addChar(text)
self.face, self.fhash, text, true) self.face, self.fhash, text, true)
fb:refresh(1, self.input_cur_x, self.input_start_y-19, 16, self.fheight) fb:refresh(1, self.input_cur_x, self.input_start_y-19, 16, self.fheight)
self.input_cur_x = self.input_cur_x + 16 self.input_cur_x = self.input_cur_x + 16
self.input_string = self.input_string .. text
end end
function InputBox:delChar() function InputBox:delChar()
@ -58,6 +60,7 @@ function InputBox:delChar()
--fill last character with blank rectangle --fill last character with blank rectangle
fb.bb:paintRect(self.input_cur_x, self.input_start_y-19, 16, self.fheight, self.input_bg) fb.bb:paintRect(self.input_cur_x, self.input_start_y-19, 16, self.fheight, self.input_bg)
fb:refresh(1, self.input_cur_x, self.input_start_y-19, 16, self.fheight) fb:refresh(1, self.input_cur_x, self.input_start_y-19, 16, self.fheight)
self.input_string = self.input_string:sub(0,-2)
end end
function InputBox:input(ypos, height) function InputBox:input(ypos, height)
@ -79,7 +82,7 @@ function InputBox:input(ypos, height)
end end
if pagedirty then if pagedirty then
fb:refresh(0, 0, ypos, fb.bb:getWidth(), height) fb:refresh(1, 20, ypos, w, h)
pagedirty = false pagedirty = false
end end
@ -141,12 +144,16 @@ function InputBox:input(ypos, height)
self:addChar("y") self:addChar("y")
elseif ev.code == KEY_Z then elseif ev.code == KEY_Z then
self:addChar("z") self:addChar("z")
elseif ev.code == KEY_SPACE then
self:addChar(" ")
elseif ev.code == KEY_PGFWD then elseif ev.code == KEY_PGFWD then
elseif ev.code == KEY_PGBCK then elseif ev.code == KEY_PGBCK then
elseif ev.code == KEY_ENTER or ev.code == KEY_FW_PRESS then elseif ev.code == KEY_ENTER or ev.code == KEY_FW_PRESS then
pagedirty = true return self.input_string
elseif ev.code == KEY_BACK then elseif ev.code == KEY_DEL then
self:delChar() self:delChar()
elseif ev.code == KEY_BACK then
return ""
end end
end end
end end

@ -116,6 +116,7 @@ function set_emu_keycodes()
KEY_FW_LEFT = 113 KEY_FW_LEFT = 113
KEY_FW_RIGHT = 114 KEY_FW_RIGHT = 114
KEY_FW_PRESS = 36 -- enter for now KEY_FW_PRESS = 36 -- enter for now
KEY_SPACE = 65
KEY_ENTER = 36 KEY_ENTER = 36

Loading…
Cancel
Save