Skip to content

Commit

Permalink
Merge pull request #1390 from cewert/fix-settings-focus
Browse files Browse the repository at this point in the history
Fix early exit from settings screen
  • Loading branch information
1hitsong authored Oct 31, 2023
2 parents 0d82374 + 28b2133 commit 949c14a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions components/settings/settings.brs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import "pkg:/source/utils/config.brs"
import "pkg:/source/utils/misc.brs"
import "pkg:/source/roku_modules/log/LogMixin.brs"
import "pkg:/source/api/sdk.bs"

sub init()
m.log = log.Logger("Settings")
Expand Down Expand Up @@ -202,16 +201,21 @@ sub radioSettingChanged()
set_user_setting(selectedSetting.settingName, m.radioSetting.content.getChild(m.radioSetting.checkedItem).id)
end sub

' Returns true if any of the data entry forms are in focus
function isFormInFocus() as boolean
if isValid(m.settingDetail.focusedChild) or m.radioSetting.hasFocus() or m.boolSetting.hasFocus() or m.integerSetting.hasFocus()
return true
end if
return false
end function

function onKeyEvent(key as string, press as boolean) as boolean
if not press then return false

if (key = "back" or key = "left") and m.settingsMenu.focusedChild <> invalid and m.userLocation.Count() > 1
LoadMenu({})
return true
else if (key = "back" or key = "left") and m.settingDetail.focusedChild <> invalid
m.settingsMenu.setFocus(true)
return true
else if (key = "back" or key = "left") and m.radioSetting.hasFocus()
else if (key = "back" or key = "left") and isFormInFocus()
m.settingsMenu.setFocus(true)
return true
end if
Expand Down

0 comments on commit 949c14a

Please sign in to comment.