Fix button focus when closing chapter menu

This commit is contained in:
1hitsong 2023-11-06 20:46:18 -05:00
parent 7fdac1b489
commit 4de113db3a
3 changed files with 21 additions and 0 deletions

View File

@ -9,6 +9,7 @@ sub init()
m.videoPlayPause = m.top.findNode("videoPlayPause")
m.top.observeField("visible", "onVisibleChanged")
m.top.observeField("hasFocus", "onFocusChanged")
m.top.observeField("playbackState", "onPlaybackStateChanged")
m.top.observeField("itemTitleText", "onItemTitleTextChanged")
@ -73,6 +74,20 @@ sub onVisibleChanged()
m.inactivityTimer.control = "stop"
end sub
' onFocusChanged: Handler for changes to the focus of this pause menu.
'
sub onFocusChanged()
if m.top.hasfocus
focusedButton = m.optionControls.getChild(m.focusedButtonIndex)
if focusedButton.focus
m.optionControls.setFocus(true)
return
end if
m.videoControls.setFocus(true)
end if
end sub
' inactiveCheck: Checks if the time since last keypress is greater than or equal to the allowed inactive time of the pause menu.
'
sub inactiveCheck()

View File

@ -24,5 +24,6 @@
<field id="playbackState" type="string" alwaysNotify="true" />
<field id="action" type="string" alwaysNotify="true" />
<field id="showChapterList" type="boolean" alwaysNotify="true" />
<field id="hasFocus" type="boolean" alwaysNotify="true" />
</interface>
</component>

View File

@ -99,6 +99,7 @@ sub handleHideAction(resume as boolean)
m.chapterList.visible = false
m.pauseMenu.showChapterList = false
m.chapterList.setFocus(false)
m.pauseMenu.hasFocus = false
m.pauseMenu.setFocus(false)
m.top.setFocus(true)
if resume
@ -115,6 +116,7 @@ sub handleChapterListAction()
m.chapterMenu.jumpToItem = getCurrentChapterIndex()
m.pauseMenu.hasFocus = false
m.pauseMenu.setFocus(false)
m.chapterMenu.setFocus(true)
end sub
@ -561,6 +563,7 @@ function onKeyEvent(key as string, press as boolean) as boolean
m.chapterList.visible = false
m.pauseMenu.showChapterList = false
m.chapterMenu.setFocus(false)
m.pauseMenu.hasFocus = true
m.pauseMenu.setFocus(true)
return true
end if
@ -608,6 +611,7 @@ function onKeyEvent(key as string, press as boolean) as boolean
if not m.LoadMetaDataTask.isIntro
' Show pause menu, but don't pause video
m.pauseMenu.visible = true
m.pauseMenu.hasFocus = true
m.pauseMenu.setFocus(true)
return true
end if
@ -627,6 +631,7 @@ function onKeyEvent(key as string, press as boolean) as boolean
' Pause video and show pause menu
m.top.control = "pause"
m.pauseMenu.visible = true
m.pauseMenu.hasFocus = true
m.pauseMenu.setFocus(true)
return true
end if