Menu: don't underline items on touch devices (#3663)

First item would be underlined if the device is both Touch and Keys
capable (emulator, android, pocketboot...), which is not really
pretty. Delay that till Keys for focusing are really used.
pull/3665/head
poire-z 6 years ago committed by Frans de Jonge
parent 5357fdde7c
commit c0c243c41a

@ -368,8 +368,20 @@ function MenuItem:init()
} }
end end
function MenuItem:onFocus() function MenuItem:onFocus(initial_focus)
self._underline_container.color = Blitbuffer.COLOR_BLACK if Device:isTouchDevice() then
-- Devices which are Keys capable will get this onFocus called by
-- updateItems(), which will toggle the underline color of first item.
-- If the device is also Touch capable, let's not show the initial
-- underline for a prettier display (it will be shown only when keys
-- are used).
if not initial_focus or self.menu.did_focus_with_keys then
self._underline_container.color = Blitbuffer.COLOR_BLACK
self.menu.did_focus_with_keys = true
end
else
self._underline_container.color = Blitbuffer.COLOR_BLACK
end
self.key_events = self.active_key_events self.key_events = self.active_key_events
return true return true
end end
@ -830,7 +842,7 @@ function Menu:updateItems(select_number)
-- reset focus manager accordingly -- reset focus manager accordingly
self.selected = { x = 1, y = select_number } self.selected = { x = 1, y = select_number }
-- set focus to requested menu item -- set focus to requested menu item
self.item_group[select_number]:onFocus() self.item_group[select_number]:onFocus(true)
end end
-- update page information -- update page information
self.page_info_text:setText(util.template(_("page %1 of %2"), self.page, self.page_num)) self.page_info_text:setText(util.template(_("page %1 of %2"), self.page, self.page_num))

Loading…
Cancel
Save