From 44d7d6cd2963d58168e2dcd84f3fe81d1e6336e5 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Mon, 19 Mar 2012 20:43:52 +0800 Subject: [PATCH] fix: handle -1 index when deleting characters in inputbox --- inputbox.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/inputbox.lua b/inputbox.lua index 65321e0d6..e30e88507 100644 --- a/inputbox.lua +++ b/inputbox.lua @@ -60,11 +60,13 @@ function InputBox:delChar() return end + local cur_index = (self.cursor.x_pos + 3 - self.input_start_x) + / self.fwidth + if cur_index == 0 then return end + self.cursor:clear() -- draw new text - local cur_index = (self.cursor.x_pos + 3 - self.input_start_x) - / self.fwidth self.input_string = self.input_string:sub(0,cur_index-1).. self.input_string:sub(cur_index+1, -1) self:refreshText()