Return to previously selected button in group when regaining focus

This commit is contained in:
1hitsong 2023-11-10 16:52:10 -05:00
parent 1ede5fe362
commit d036abaa6b

View File

@ -15,6 +15,10 @@ sub init()
m.defaultButtonIndex = 1
m.focusedButtonIndex = 1
m.videoControls.buttonFocused = m.defaultButtonIndex
m.optionControls.buttonFocused = m.optionControls.getChildCount() - 1
m.videoControls.getChild(m.defaultButtonIndex).focus = true
m.deviceInfo = CreateObject("roDeviceInfo")
end sub
@ -58,6 +62,8 @@ sub resetFocusToDefaultButton()
m.videoControls.setFocus(true)
m.focusedButtonIndex = m.defaultButtonIndex
m.videoControls.getChild(m.defaultButtonIndex).focus = true
m.videoControls.buttonFocused = 1
m.optionControls.buttonFocused = m.optionControls.getChildCount() - 1
end sub
' onVisibleChanged: Handler for changes to the visibility of this pause menu.
@ -147,6 +153,7 @@ function onKeyEvent(key as string, press as boolean) as boolean
focusedButton = buttonGroup.getChild(m.focusedButtonIndex)
if isValid(focusedButton.focus)
buttonGroup.buttonFocused = m.focusedButtonIndex
focusedButton.focus = true
exit for
end if
@ -175,6 +182,7 @@ function onKeyEvent(key as string, press as boolean) as boolean
focusedButton = buttonGroup.getChild(m.focusedButtonIndex)
if isValid(focusedButton.focus)
buttonGroup.buttonFocused = m.focusedButtonIndex
focusedButton.focus = true
exit for
end if
@ -189,7 +197,7 @@ function onKeyEvent(key as string, press as boolean) as boolean
focusedButton.focus = false
m.videoControls.setFocus(false)
m.focusedButtonIndex = 2
m.focusedButtonIndex = m.optionControls.buttonFocused
focusedButton = m.optionControls.getChild(m.focusedButtonIndex)
focusedButton.focus = true
m.optionControls.setFocus(true)
@ -204,8 +212,8 @@ function onKeyEvent(key as string, press as boolean) as boolean
focusedButton.focus = false
m.optionControls.setFocus(false)
m.focusedButtonIndex = m.defaultButtonIndex
focusedButton = m.videoControls.getChild(m.defaultButtonIndex)
m.focusedButtonIndex = m.videoControls.buttonFocused
focusedButton = m.videoControls.getChild(m.focusedButtonIndex)
focusedButton.focus = true
m.videoControls.setFocus(true)
end if