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 = 'Theme',
{ text = 'Light', key = 'ctrl-l' },
{ text = 'Dark', key = 'ctrl-d' },
{ text = 'Light', key = 'ctrl-l', id = 'themeLight', },
{ text = 'Dark', key = 'ctrl-d', id = 'themeDark' },
},
{ text = 'Style',
{ text = 'Default' },
@@ -163,6 +163,6 @@ layout.mainCanvas.align = 'top'
layout.menuQuit:onPress(function (event) love.event.quit() end)
layout.themeLight:onPress(function (event) love.event.quit() end)
layout:show()

View File

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

View File

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