1
0
mirror of https://github.com/kepler155c/opus synced 2024-12-24 15:40:26 +00:00

better emits

This commit is contained in:
kepler155c@gmail.com 2017-12-16 00:07:22 -05:00
parent dd4211745e
commit 743959c1fa

View File

@ -2756,14 +2756,14 @@ function UI.TextEntry:eventHandler(event)
self.value = input:sub(1, self.pos-1) .. input:sub(self.pos+1)
self.pos = self.pos - 1
self:draw()
self:emit({ type = 'text_change', text = self.value })
self:emit({ type = 'text_change', text = self.value, element = self })
end
elseif ch == 'delete' then
local input = tostring(self.value)
if self.pos < #input then
self.value = input:sub(1, self.pos) .. input:sub(self.pos+2)
self:draw()
self:emit({ type = 'text_change', text = self.value })
self:emit({ type = 'text_change', text = self.value, element = self })
end
elseif #ch == 1 then
local input = tostring(self.value)
@ -2771,7 +2771,7 @@ function UI.TextEntry:eventHandler(event)
self.value = input:sub(1, self.pos) .. ch .. input:sub(self.pos+1)
self.pos = self.pos + 1
self:draw()
self:emit({ type = 'text_change', text = self.value })
self:emit({ type = 'text_change', text = self.value, element = self })
end
else
return false
@ -2791,7 +2791,7 @@ function UI.TextEntry:eventHandler(event)
self.pos = self.pos + #text
self:draw()
self:updateCursor()
self:emit({ type = 'text_change', text = self.value })
self:emit({ type = 'text_change', text = self.value, element = self })
return true
elseif event.type == 'mouse_click' then
@ -2804,7 +2804,7 @@ function UI.TextEntry:eventHandler(event)
local input = tostring(self.value)
if #input > 0 then
self:reset()
self:emit({ type = 'text_change', text = self.value })
self:emit({ type = 'text_change', text = self.value, element = self })
end
end