diff --git a/inputbox.lua b/inputbox.lua index 1aca2462d..239267d5b 100644 --- a/inputbox.lua +++ b/inputbox.lua @@ -138,8 +138,10 @@ end -- -- @title: input prompt for the box -- @d_text: default to nil (used to set default text in input slot) +-- @is_hint: if this arg is true, default text will be used as hint +-- message for input ---------------------------------------------------------------------- -function InputBox:input(ypos, height, title, d_text) +function InputBox:input(ypos, height, title, d_text, is_hint) self:init() -- do some initilization self.ypos = ypos @@ -161,10 +163,21 @@ function InputBox:input(ypos, height, title, d_text) self:drawHelpMsg(ypos, w, h) self:drawBox(ypos, w, h, title) if d_text then - self.input_string = d_text - self.input_cur_x = self.input_cur_x + (self.fwidth * d_text:len()) - self.cursor.x_pos = self.cursor.x_pos + (self.fwidth * d_text:len()) - self:refreshText() + if is_hint then + -- print hint text + fb.bb:paintRect(140, self.input_start_y-19, + self.input_slot_w, self.fheight, self.input_bg) + renderUtf8Text(fb.bb, self.input_start_x+5, self.input_start_y, + self.face, + d_text, 0) + fb.bb:dimRect(140, self.input_start_y-19, + self.input_slot_w, self.fheight, self.input_bg) + else + self.input_string = d_text + self.input_cur_x = self.input_cur_x + (self.fwidth * d_text:len()) + self.cursor.x_pos = self.cursor.x_pos + (self.fwidth * d_text:len()) + self:refreshText() + end end self.cursor:draw() fb:refresh(1, 20, ypos, w, h) diff --git a/unireader.lua b/unireader.lua index 82c984347..40801215f 100644 --- a/unireader.lua +++ b/unireader.lua @@ -1921,7 +1921,8 @@ function UniReader:addAllCommands() self.commands:add(KEY_G,nil,"G", "open 'go to page' input box", function(unireader) - local page = NumInputBox:input(G_height-100, 100, "Page:") + local page = NumInputBox:input(G_height-100, 100, + "Page:", "current page "..self.pageno, true) -- convert string to number if not pcall(function () page = page + 0 end) then page = unireader.pageno