minor bug fixes

This commit is contained in:
airstruck
2015-12-02 01:42:35 -05:00
parent 14b96f4cb5
commit a902385d55
10 changed files with 131 additions and 25 deletions

View File

@@ -123,6 +123,25 @@ local function registerLayoutEvents (self)
end
end)
menuLayout:onPress(function (event)
for widget in event.target:eachAncestor(true) do
if widget.type == 'menu.item' and #widget.items == 0 then
menuLayout:hide()
deactivateSiblings(self.rootMenu[1])
end
end
end)
menuLayout:onPressEnd(function (event)
for widget in event.target:eachAncestor(true) do
if widget.type == 'menu.item' and #widget.items == 0
and event.target ~= event.origin then
widget:bubbleEvent('Press', event)
end
end
end)
menuLayout:onEnter(activate)
menuLayout:onPressEnter(activate)
end

View File

@@ -200,6 +200,20 @@ return function (self)
end)
self:onKeyPress(function (event)
-- ignore tabs (keyboard navigation)
if event.key == 'tab' then
return
end
-- focus next widget on enter (keyboard navigation)
if event.key == 'return' then
self.layout:focusNextWidget()
-- if the next widget is a button, allow the event to propagate
-- so that the button is pressed (TODO: is this a good idea?)
return self.layout.focusedWidget.type ~= 'button' or nil
end
if event.key == 'backspace' then
if not deleteRange(self) then