give keyboard shortcuts precedence over default tab/space/return behavior, fixes #10

This commit is contained in:
airstruck
2015-12-11 22:32:41 -05:00
parent c8ca310811
commit f95b8f53c1

View File

@@ -265,6 +265,16 @@ function Layout:addDefaultHandlers ()
self:onKeyPress(function (event)
-- keyboard accelerators
local entry = self.accelerators[event.modifierFlags]
local acceleratedWidget = entry and entry[event.key]
if acceleratedWidget then
acceleratedWidget.hovered = true
self.input:handlePressStart(self, event.key, event.x, event.y,
acceleratedWidget, event.key)
return false
end
-- tab/shift-tab cycles focused widget
if event.key == 'tab' then
if Backend.isKeyDown('lshift', 'rshift') then
@@ -283,16 +293,6 @@ function Layout:addDefaultHandlers ()
widget, event.key)
return false
end
-- accelerators
local entry = self.accelerators[event.modifierFlags]
local acceleratedWidget = entry and entry[event.key]
if acceleratedWidget then
acceleratedWidget.hovered = true
self.input:handlePressStart(self, event.key, event.x, event.y,
acceleratedWidget, event.key)
return false
end
end)
self:onKeyRelease(function (event)