mirror of
https://github.com/kepler155c/opus
synced 2025-01-15 18:05:42 +00:00
funnel all events through emit
This commit is contained in:
parent
0a828fecc5
commit
db48031c7c
@ -62,13 +62,15 @@ function Entry:copyText(cx, ex)
|
||||
end
|
||||
|
||||
function Entry:insertText(x, text)
|
||||
text = tostring(self.transform(text)) or ''
|
||||
local value = _val(self.value)
|
||||
if #value + #text > self.limit then
|
||||
text = text:sub(1, self.limit-#value)
|
||||
text = tostring(self.transform(text) or '')
|
||||
if #text > 0 then
|
||||
local value = _val(self.value)
|
||||
if #value + #text > self.limit then
|
||||
text = text:sub(1, self.limit-#value)
|
||||
end
|
||||
self.value = self.transform(value:sub(1, x) .. text .. value:sub(x + 1))
|
||||
self.pos = self.pos + #text
|
||||
end
|
||||
self.value = self.transform(value:sub(1, x) .. text .. value:sub(x + 1))
|
||||
self.pos = self.pos + #text
|
||||
end
|
||||
|
||||
function Entry:deleteText(sx, ex)
|
||||
|
@ -248,23 +248,8 @@ function Manager:emitEvent(event)
|
||||
end
|
||||
end
|
||||
|
||||
function Manager:inputEvent(parent, event)
|
||||
while parent do
|
||||
if parent.accelerators then
|
||||
local acc = parent.accelerators[event.key]
|
||||
if acc then
|
||||
if parent:emit({ type = acc, element = parent }) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
if parent.eventHandler then
|
||||
if parent:eventHandler(event) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
parent = parent.parent
|
||||
end
|
||||
function Manager:inputEvent(parent, event) -- deprecate ?
|
||||
return parent and parent:emit(event)
|
||||
end
|
||||
|
||||
function Manager:click(target, code, button, x, y)
|
||||
@ -927,6 +912,14 @@ end
|
||||
function UI.Window:emit(event)
|
||||
local parent = self
|
||||
while parent do
|
||||
if parent.accelerators and event.key then -- not ideal
|
||||
-- could be [event.key or event.type] to support accelerators
|
||||
-- for non-input type events
|
||||
local acc = parent.accelerators[event.key]
|
||||
if acc and parent:emit({ type = acc, element = parent }) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
if parent.eventHandler then
|
||||
if parent:eventHandler(event) then
|
||||
return true
|
||||
|
Loading…
Reference in New Issue
Block a user