Skip to content

Commit

Permalink
Fix button focus when closing chapter menu
Browse files Browse the repository at this point in the history
  • Loading branch information
1hitsong committed Nov 7, 2023
1 parent 7fdac1b commit 4de113d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions components/video/PauseMenu.bs
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions components/video/PauseMenu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
5 changes: 5 additions & 0 deletions components/video/VideoPlayerView.brs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -115,6 +116,7 @@ sub handleChapterListAction()

m.chapterMenu.jumpToItem = getCurrentChapterIndex()

m.pauseMenu.hasFocus = false
m.pauseMenu.setFocus(false)
m.chapterMenu.setFocus(true)
end sub
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 4de113d

Please sign in to comment.