Skip to content
Snippets Groups Projects
Commit 61ee43ab authored by dg's avatar dg
Browse files

Ignore escape in text/numberboxes

git-svn-id: http://svn.net-core.org/repos/t-engine4@2904 51575b47-30f0-44d4-a5cc-537603b46e54
parent f660594e
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,7 @@ module(..., package.seeall, class.inherit(engine.Key))
function _M:init()
engine.Key.init(self)
self.commands = {}
self.ignore = {}
self.on_input = false
self.locale_convert = {}
......@@ -54,6 +55,8 @@ function _M:receiveKey(sym, ctrl, shift, alt, meta, unicode, isup)
if isup then return end
if self.ignore[sym] then return end
-- Convert locale
sym = self.locale_convert[sym] or sym
......@@ -110,6 +113,16 @@ function _M:addCommand(sym, mods, fct, anymod)
if anymod then self.commands[sym].anymod = true end
end
--- Adds a key to be fully ignored
-- @param sym the key to handle
-- @param v boolean to ignore or not
function _M:addIgnore(sym, v)
if type(sym) == "string" then sym = self[sym] end
if not sym then return end
self.ignore[sym] = v
end
--- Adds many key/command at once
-- @usage self.key:addCommands{<br/>
-- _LEFT = function()<br/>
......
......@@ -85,6 +85,7 @@ function _M:generate()
self.key:addBind("MOVE_DOWN", function() self.first = false self:updateText(-1) end)
self.key:addBind("MOVE_LEFT", function() self.first = false self.cursor = util.bound(self.cursor - 1, 1, #self.tmp+1) self.scroll = util.scroll(self.cursor, self.scroll, self.max_display) self:updateText() end)
self.key:addBind("MOVE_RIGHT", function() self.first = false self.cursor = util.bound(self.cursor + 1, 1, #self.tmp+1) self.scroll = util.scroll(self.cursor, self.scroll, self.max_display) self:updateText() end)
self.key:addIgnore("_ESCAPE", v)
self.key:addCommands{
_DELETE = function()
if self.first then self.first = false self.tmp = {} self:updateText() end
......
......@@ -80,6 +80,7 @@ function _M:generate()
end
end)
self.key:addBind("ACCEPT", function() self.fct(self.text) end)
self.key:addIgnore("_ESCAPE", v)
self.key:addCommands{
_LEFT = function() self.cursor = util.bound(self.cursor - 1, 1, #self.tmp+1) self.scroll = util.scroll(self.cursor, self.scroll, self.max_display) self:updateText() end,
_RIGHT = function() self.cursor = util.bound(self.cursor + 1, 1, #self.tmp+1) self.scroll = util.scroll(self.cursor, self.scroll, self.max_display) self:updateText() end,
......
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