This commit is contained in:
airstruck
2015-11-08 16:49:50 -05:00
parent 86bca676b3
commit f866442cf1
3 changed files with 22 additions and 23 deletions

View File

@@ -16,11 +16,6 @@ local function unhook (item)
if hooks[item.host][item.key] == item then if hooks[item.host][item.key] == item then
hooks[item.host][item.key] = item.next hooks[item.host][item.key] = item.next
end end
item.host = nil
item.prev = nil
item.next = nil
item.func = nil
end end
local function hook (host, key, func, atEnd) local function hook (host, key, func, atEnd)
@@ -81,17 +76,14 @@ function Hooker.hook (host, key, func, atEnd)
local item = hooks[host][key] local item = hooks[host][key]
while item do while item do
local nextItem = item.next local result = item.func(...)
if item.func then if result ~= nil then
local result = item.func(...) return result
if result ~= nil then
return result
end
end end
item = nextItem item = item.next
end end -- while
end end -- function
end end -- if
return hook(host, key, func, atEnd) return hook(host, key, func, atEnd)
end end

View File

@@ -166,10 +166,12 @@ function Input:handlePressStart (layout, button, x, y, widget, accelerator)
hit = nil hit = nil
widget = layout.root widget = layout.root
end end
widget.pressed = true if hit then
self.pressedWidgets[button] = widget widget.pressed = true
self.passedWidgets[button] = widget self.pressedWidgets[button] = widget
widget:focus() self.passedWidgets[button] = widget
widget:focus()
end
widget:bubbleEvent('PressStart', { widget:bubbleEvent('PressStart', {
hit = hit, hit = hit,
button = button, button = button,
@@ -188,7 +190,9 @@ function Input:handlePressEnd (layout, button, x, y, widget, accelerator)
end end
local originWidget = self.pressedWidgets[button] local originWidget = self.pressedWidgets[button]
if not originWidget then return end if not originWidget then return end
originWidget.pressed = nil if hit then
originWidget.pressed = nil
end
widget:bubbleEvent('PressEnd', { widget:bubbleEvent('PressEnd', {
hit = hit, hit = hit,
origin = originWidget, origin = originWidget,
@@ -203,8 +207,10 @@ function Input:handlePressEnd (layout, button, x, y, widget, accelerator)
x = x, y = y x = x, y = y
}) })
end end
self.pressedWidgets[button] = nil if hit then
self.passedWidgets[button] = nil self.pressedWidgets[button] = nil
self.passedWidgets[button] = nil
end
return hit return hit
end end

View File

@@ -93,7 +93,7 @@ show = function (self)
local tw = child.fontData:getAdvance(child[2].text) local tw = child.fontData:getAdvance(child[2].text)
+ pad * 2 + h + pad * 2 + h
local kw = child.fontData:getAdvance(child[3].text) local kw = child.fontData:getAdvance(child[3].text)
+ pad * 2 + pad * 4
textWidth = math.max(textWidth, tw) textWidth = math.max(textWidth, tw)
keyWidth = math.max(keyWidth, kw) keyWidth = math.max(keyWidth, kw)
end end
@@ -144,6 +144,7 @@ return function (self)
end end
if isSubmenu then if isSubmenu then
key = #self.items > 0 and '>' or key
self.height = self.fontData:getLineHeight() + pad * 2 self.height = self.fontData:getLineHeight() + pad * 2
self.flow = 'x' self.flow = 'x'
self:addChild({ icon = icon, width = self.height }) self:addChild({ icon = icon, width = self.height })