mirror of
https://github.com/airstruck/luigi.git
synced 2025-11-18 12:25:06 +00:00
cleanup
This commit is contained in:
@@ -16,11 +16,6 @@ local function unhook (item)
|
||||
if hooks[item.host][item.key] == item then
|
||||
hooks[item.host][item.key] = item.next
|
||||
end
|
||||
|
||||
item.host = nil
|
||||
item.prev = nil
|
||||
item.next = nil
|
||||
item.func = nil
|
||||
end
|
||||
|
||||
local function hook (host, key, func, atEnd)
|
||||
@@ -81,17 +76,14 @@ function Hooker.hook (host, key, func, atEnd)
|
||||
local item = hooks[host][key]
|
||||
|
||||
while item do
|
||||
local nextItem = item.next
|
||||
if item.func then
|
||||
local result = item.func(...)
|
||||
if result ~= nil then
|
||||
return result
|
||||
end
|
||||
local result = item.func(...)
|
||||
if result ~= nil then
|
||||
return result
|
||||
end
|
||||
item = nextItem
|
||||
end
|
||||
end
|
||||
end
|
||||
item = item.next
|
||||
end -- while
|
||||
end -- function
|
||||
end -- if
|
||||
|
||||
return hook(host, key, func, atEnd)
|
||||
end
|
||||
|
||||
@@ -166,10 +166,12 @@ function Input:handlePressStart (layout, button, x, y, widget, accelerator)
|
||||
hit = nil
|
||||
widget = layout.root
|
||||
end
|
||||
widget.pressed = true
|
||||
self.pressedWidgets[button] = widget
|
||||
self.passedWidgets[button] = widget
|
||||
widget:focus()
|
||||
if hit then
|
||||
widget.pressed = true
|
||||
self.pressedWidgets[button] = widget
|
||||
self.passedWidgets[button] = widget
|
||||
widget:focus()
|
||||
end
|
||||
widget:bubbleEvent('PressStart', {
|
||||
hit = hit,
|
||||
button = button,
|
||||
@@ -188,7 +190,9 @@ function Input:handlePressEnd (layout, button, x, y, widget, accelerator)
|
||||
end
|
||||
local originWidget = self.pressedWidgets[button]
|
||||
if not originWidget then return end
|
||||
originWidget.pressed = nil
|
||||
if hit then
|
||||
originWidget.pressed = nil
|
||||
end
|
||||
widget:bubbleEvent('PressEnd', {
|
||||
hit = hit,
|
||||
origin = originWidget,
|
||||
@@ -203,8 +207,10 @@ function Input:handlePressEnd (layout, button, x, y, widget, accelerator)
|
||||
x = x, y = y
|
||||
})
|
||||
end
|
||||
self.pressedWidgets[button] = nil
|
||||
self.passedWidgets[button] = nil
|
||||
if hit then
|
||||
self.pressedWidgets[button] = nil
|
||||
self.passedWidgets[button] = nil
|
||||
end
|
||||
return hit
|
||||
end
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ show = function (self)
|
||||
local tw = child.fontData:getAdvance(child[2].text)
|
||||
+ pad * 2 + h
|
||||
local kw = child.fontData:getAdvance(child[3].text)
|
||||
+ pad * 2
|
||||
+ pad * 4
|
||||
textWidth = math.max(textWidth, tw)
|
||||
keyWidth = math.max(keyWidth, kw)
|
||||
end
|
||||
@@ -144,6 +144,7 @@ return function (self)
|
||||
end
|
||||
|
||||
if isSubmenu then
|
||||
key = #self.items > 0 and '>' or key
|
||||
self.height = self.fontData:getLineHeight() + pad * 2
|
||||
self.flow = 'x'
|
||||
self:addChild({ icon = icon, width = self.height })
|
||||
|
||||
Reference in New Issue
Block a user