[Readtimer] bug fix: fix focus when setting a timer (#14420)

This commit is contained in:
David
2025-10-14 13:05:27 +01:00
committed by GitHub
parent 87445034bd
commit 4557ee9524
2 changed files with 18 additions and 2 deletions

View File

@@ -133,8 +133,9 @@ function DateTimeWidget:init()
-- Actually the widget layout
self:createLayout()
self.non_touch_with_action_dpad = Device:hasDPad() and Device:useDPadAsActionKeys() and not Device:isTouchDevice()
-- Move focus to OK button on NT devices with key_events, saves time for users
if Device:hasDPad() and Device:useDPadAsActionKeys() and not Device:isTouchDevice() then
if self.non_touch_with_action_dpad then
-- Since button table is the last row in our layout, and OK is the last button
-- We need to set focus to both last row, and last column
local last_row = #self.layout
@@ -468,6 +469,13 @@ function DateTimeWidget:addWidget(widget)
widget,
}
table.insert(self.date_frame[1], #self.date_frame[1], widget)
if self.non_touch_with_action_dpad then
-- We need to reset focus again, otherwise FocusManager will not know about the new additions
-- and the cursor keys will become unresponsive.
local last_row = #self.layout
local last_col = #self.layout[last_row]
self:moveFocusTo(last_col, last_row)
end
end
function DateTimeWidget:getAddedWidgetAvailableWidth()

View File

@@ -93,8 +93,9 @@ function SpinWidget:init()
-- Actually the widget layout
self:update()
self.non_touch_with_action_dpad = Device:hasDPad() and Device:useDPadAsActionKeys() and not Device:isTouchDevice()
-- Move focus to OK button on NT devices with key_events, saves time for users
if Device:hasDPad() and Device:useDPadAsActionKeys() and not Device:isTouchDevice() then
if self.non_touch_with_action_dpad then
-- Since button table is the last row in our layout, and OK is the last button
-- We need to set focus to both last row, and last column
local last_row = #self.layout
@@ -316,6 +317,13 @@ function SpinWidget:addWidget(widget, re_init)
-- Insert widget before the bottom buttons and their previous vspan.
-- This is different to InputDialog.
table.insert(self.vgroup, #self.vgroup, widget)
if self.non_touch_with_action_dpad then
-- We need to reset focus again, otherwise FocusManager will not know about the new additions
-- and the cursor keys will become unresponsive.
local last_row = #self.layout
local last_col = #self.layout[last_row]
self:moveFocusTo(last_col, last_row)
end
end
function SpinWidget:getAddedWidgetAvailableWidth()