Skip to content
Snippets Groups Projects
Commit 2874d055 authored by Alex Ksandra's avatar Alex Ksandra
Browse files

numberbox behaves more sanily when used backspace/delete in it

parent 16e44645
No related branches found
No related tags found
1 merge request!267Small fixes
......@@ -50,11 +50,11 @@ function _M:generate()
self.key:addIgnore("_DOWN", false)
self.key:addCommands{
_UP = function() self.first = false self:updateText(1) end,
_DOWN = function() self.first = false self:updateText(-1) end,
_UP = function() self:updateText(1) end,
_DOWN = function() self:updateText(-1) end,
__TEXTINPUT = function(c)
if self.first then self.first = false self.tmp = {} self.cursor = 1 end
if #self.tmp and (c == '-' or c == '0' or c == '1' or c == '2' or c == '3' or c == '4' or c == '5' or c == '6' or c == '7' or c == '8' or c == '9') then
if #self.tmp and ((self.cursor == 1 and c == '-') or (c >= '0' and c <= '9')) then
table.insert(self.tmp, self.cursor, c)
self.cursor = self.cursor + 1
self.scroll = util.scroll(self.cursor, self.scroll, self.max_display)
......@@ -65,6 +65,7 @@ function _M:generate()
end
function _M:updateText(v)
self.first = false
local old = self.number
if not v then
self.number = self.tmp and tonumber(table.concat(self.tmp)) or 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment