Fix for input field focus

This commit is contained in:
Brahim Hadriche committed 2023-07-06 16:08:54 -04:00
1 parent 5d38b325c5
commit e49aa9b7d8
3 files changed
+14 -13

No files matched your search

+1
View File
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Crash when loading the home screen [#83](https://github.com/iBicha/playlet/issues/83) - Crash when loading the home screen [#83](https://github.com/iBicha/playlet/issues/83)
- Performance of home screen in web app - Performance of home screen in web app
- SponsorBlock segments where video duration is not provided (follow up to [#23](https://github.com/iBicha/playlet/pull/23)) - SponsorBlock segments where video duration is not provided (follow up to [#23](https://github.com/iBicha/playlet/pull/23))
- Focus with the settings input field
## [0.10.1] - 2023-06-28 ## [0.10.1] - 2023-06-28
@@ -275,18 +275,22 @@ function OnkeyEvent(key as string, press as boolean) as boolean
end function end function
function GetFocusedControl() as object function GetFocusedControl() as object
focusedChild = m.top.focusedChild node = m.top.focusedChild
if focusedChild = invalid if node = invalid
return invalid return invalid
end if end if
while not focusedChild.id.StartsWith("Control") while not node.id.StartsWith("Control")
focusedChild = focusedChild.focusedChild child = node.focusedChild
if focusedChild = invalid if child = invalid
return invalid return invalid
end if end if
if node.isSameNode(child)
return invalid
end if
node = child
end while end while
return focusedChild return node
end function end function
function MenuGoLeft() as boolean function MenuGoLeft() as boolean
@@ -299,6 +303,9 @@ end function
function MenuNavigate(direction as integer) as boolean function MenuNavigate(direction as integer) as boolean
focusedControl = GetFocusedControl() focusedControl = GetFocusedControl()
if focusedControl = invalid
return false
end if
container = focusedControl.getParent() container = focusedControl.getParent()
containerParent = container.getParent() containerParent = container.getParent()
containerCount = containerParent.getChildCount() containerCount = containerParent.getChildCount()
@@ -3,7 +3,6 @@ function Init()
m.top.observeField("focusedChild", "OnFocusChanged") m.top.observeField("focusedChild", "OnFocusChanged")
m.top.observeField("value", "OnValueChanged") m.top.observeField("value", "OnValueChanged")
m.top.observeField("settings", "OnSettingsScreen") m.top.observeField("settings", "OnSettingsScreen")
m.keyboardWasClosedByButton = false
end function end function
function OnSettingsScreen() function OnSettingsScreen()
@@ -45,15 +44,9 @@ function OnButtonSelected(event as object)
if buttonSelected = 0 if buttonSelected = 0
m.top.value = keyboard.text m.top.value = keyboard.text
end if end if
m.keyboardWasClosedByButton = true
keyboard.close = true keyboard.close = true
end function end function
function OnKeyboardClosed() as void function OnKeyboardClosed() as void
' The keyboard was closed by something else (like cast from web app)
' In this case, we do nothing, since the focus might be moved to the video player
if not m.keyboardWasClosedByButton
return
end if
m.top.settings@.MenuNavigate(-1) m.top.settings@.MenuNavigate(-1)
end function end function