From 2c24ba3ca076ad4a5ef08f746c2b2b5886251972 Mon Sep 17 00:00:00 2001 From: Matthias Richter Date: Wed, 6 Feb 2013 13:28:23 +0100 Subject: Input-widget only fires event when activated --- input.lua | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/input.lua b/input.lua index ccace0d..17c372f 100644 --- a/input.lua +++ b/input.lua @@ -42,18 +42,15 @@ return function(w) keyboard.makeCyclable(id) if mouse.isActive(id) then keyboard.setFocus(id) end - local changed = false if not keyboard.hasFocus(id) then --[[nothing]] -- editing elseif keyboard.key == 'backspace' then w.info.text = w.info.text:sub(1,w.info.cursor-1) .. w.info.text:sub(w.info.cursor+1) w.info.cursor = math.max(0, w.info.cursor-1) - changed = true elseif keyboard.key == 'delete' then w.info.text = w.info.text:sub(1,w.info.cursor) .. w.info.text:sub(w.info.cursor+2) w.info.cursor = math.min(w.info.text:len(), w.info.cursor) - changed = true -- movement elseif keyboard.key == 'left' then w.info.cursor = math.max(0, w.info.cursor-1) @@ -72,11 +69,10 @@ return function(w) local right = w.info.text:sub(w.info.cursor+1) w.info.text = table.concat{left, string.char(keyboard.code), right} w.info.cursor = w.info.cursor + 1 - changed = true end core.registerDraw(id, w.draw or core.style.Input, w.info.text, w.info.cursor, pos[1],pos[2], size[1],size[2]) - return changed + return mouse.releasedOn(id) or (keyboard.key == 'return' and keyboard.hasFocus(id)) end -- cgit v1.2.3-54-g00ecf