ExternalKeyboard: Don't keep the menu open on toggle, the event cascade

may reinit stuff and close it anyway.
reviewable/pr9739/r1
NiLuJe 2 years ago
parent 09498d4bbb
commit d585cd5d86

@ -130,15 +130,14 @@ function ExternalKeyboard:addToMainMenu(menu_items)
sub_item_table = { sub_item_table = {
{ {
text = _("Enable OTG mode to connect peripherals"), text = _("Enable OTG mode to connect peripherals"),
keep_menu_open = true,
checked_func = function() checked_func = function()
return self:getOTGRole() == USB_ROLE_HOST return self:getOTGRole() == USB_ROLE_HOST
end, end,
callback = function(touchmenu_instance) callback = function(touchmenu_instance)
local role = self:getOTGRole() local role = self:getOTGRole()
local new_role = (role == USB_ROLE_DEVICE) and USB_ROLE_HOST or USB_ROLE_DEVICE local new_role = (role == USB_ROLE_DEVICE) and USB_ROLE_HOST or USB_ROLE_DEVICE
self:setOTGRole(new_role) -- Let the menu close itself first, as the event cascade might reinit stuff and close it anyway
touchmenu_instance:updateItems() UIManager:nextTick(self.setOTGRole, self, new_role)
end, end,
}, },
{ {

Loading…
Cancel
Save