mirror of
https://github.com/kepler155c/opus
synced 2025-01-27 07:34:45 +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
|
end
|
||||||
|
|
||||||
function Entry:insertText(x, text)
|
function Entry:insertText(x, text)
|
||||||
text = tostring(self.transform(text)) or ''
|
text = tostring(self.transform(text) or '')
|
||||||
local value = _val(self.value)
|
if #text > 0 then
|
||||||
if #value + #text > self.limit then
|
local value = _val(self.value)
|
||||||
text = text:sub(1, self.limit-#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
|
end
|
||||||
self.value = self.transform(value:sub(1, x) .. text .. value:sub(x + 1))
|
|
||||||
self.pos = self.pos + #text
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Entry:deleteText(sx, ex)
|
function Entry:deleteText(sx, ex)
|
||||||
|
@ -248,23 +248,8 @@ function Manager:emitEvent(event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Manager:inputEvent(parent, event)
|
function Manager:inputEvent(parent, event) -- deprecate ?
|
||||||
while parent do
|
return parent and parent:emit(event)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Manager:click(target, code, button, x, y)
|
function Manager:click(target, code, button, x, y)
|
||||||
@ -927,6 +912,14 @@ end
|
|||||||
function UI.Window:emit(event)
|
function UI.Window:emit(event)
|
||||||
local parent = self
|
local parent = self
|
||||||
while parent do
|
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 then
|
||||||
if parent:eventHandler(event) then
|
if parent:eventHandler(event) then
|
||||||
return true
|
return true
|
||||||
|
Loading…
Reference in New Issue
Block a user