don't trap key events

This commit is contained in:
airstruck
2015-11-12 01:56:41 -05:00
parent 6aaa128463
commit b706f663e4
3 changed files with 12 additions and 31 deletions

View File

@@ -46,8 +46,8 @@ local mainForm = { id = 'mainWindow', type = 'panel',
}, },
{ text = 'View', { text = 'View',
{ text = 'Theme', { text = 'Theme',
{ text = 'Light', key = 'ctrl-l' }, { text = 'Light', key = 'ctrl-l', id = 'themeLight', },
{ text = 'Dark', key = 'ctrl-d' }, { text = 'Dark', key = 'ctrl-d', id = 'themeDark' },
}, },
{ text = 'Style', { text = 'Style',
{ text = 'Default' }, { text = 'Default' },
@@ -163,6 +163,6 @@ layout.mainCanvas.align = 'top'
layout.menuQuit:onPress(function (event) love.event.quit() end) layout.menuQuit:onPress(function (event) love.event.quit() end)
layout.themeLight:onPress(function (event) love.event.quit() end)
layout:show() layout:show()

View File

@@ -29,53 +29,34 @@ function Input:getModifierFlags ()
end end
function Input:handleKeyPress (layout, key, x, y) function Input:handleKeyPress (layout, key, x, y)
local widget = layout.focusedWidget or layout:getWidgetAt(x, y) local widget = layout.focusedWidget or layout.root
local hit = true
if not widget then
hit = nil
widget = layout.root
end
local result = widget:bubbleEvent('KeyPress', { local result = widget:bubbleEvent('KeyPress', {
hit = hit,
key = key, key = key,
modifierFlags = self:getModifierFlags(), modifierFlags = self:getModifierFlags(),
x = x, x = x,
y = y y = y
}) })
if result ~= nil then return result end if result ~= nil then return result end
return hit
end end
function Input:handleKeyRelease (layout, key, x, y) function Input:handleKeyRelease (layout, key, x, y)
local widget = layout.focusedWidget or layout:getWidgetAt(x, y) local widget = layout.focusedWidget or layout.root
local hit = true
if not widget then
hit = nil
widget = layout.root
end
local result = widget:bubbleEvent('KeyRelease', { local result = widget:bubbleEvent('KeyRelease', {
hit = hit,
key = key, key = key,
modifierFlags = self:getModifierFlags(), modifierFlags = self:getModifierFlags(),
x = x, x = x,
y = y y = y
}) })
if result ~= nil then return result end if result ~= nil then return result end
return hit
end end
function Input:handleTextInput (layout, text, x, y) function Input:handleTextInput (layout, text, x, y)
local widget = layout.focusedWidget or layout:getWidgetAt(x, y) local widget = layout.focusedWidget or layout.root
local hit = true local result = widget:bubbleEvent('TextInput', {
if not widget then
hit = nil
widget = layout.root
end
widget:bubbleEvent('TextInput', {
hit = hit, hit = hit,
text = text, x = x, y = y text = text, x = x, y = y
}) })
return hit if result ~= nil then return result end
end end
function Input:handleMove (layout, x, y) function Input:handleMove (layout, x, y)

View File

@@ -55,18 +55,18 @@ local function deactivateSiblings (target)
end end
while sibling do while sibling do
local layout = sibling.menuLayout
local items = sibling.items
sibling.active = nil sibling.active = nil
local layout = sibling.menuLayout
if layout and layout.isShown then if layout and layout.isShown then
wasSiblingOpen = true wasSiblingOpen = true
layout:hide() layout:hide()
end end
if sibling.items and sibling.items[1] then if items and items[1] then
deactivateSiblings(sibling.items[1]) deactivateSiblings(items[1])
end end
sibling = sibling:getNextSibling() sibling = sibling:getNextSibling()