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)
- 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))
- Focus with the settings input field
## [0.10.1] - 2023-06-28
@@ -275,18 +275,22 @@ function OnkeyEvent(key as string, press as boolean) as boolean
end function
function GetFocusedControl() as object
focusedChild = m.top.focusedChild
if focusedChild = invalid
node = m.top.focusedChild
if node = invalid
return invalid
end if
while not focusedChild.id.StartsWith("Control")
focusedChild = focusedChild.focusedChild
if focusedChild = invalid
while not node.id.StartsWith("Control")
child = node.focusedChild
if child = invalid
return invalid
end if
if node.isSameNode(child)
return invalid
end if
node = child
end while
return focusedChild
return node
end function
function MenuGoLeft() as boolean
@@ -299,6 +303,9 @@ end function
function MenuNavigate(direction as integer) as boolean
focusedControl = GetFocusedControl()
if focusedControl = invalid
return false
end if
container = focusedControl.getParent()
containerParent = container.getParent()
containerCount = containerParent.getChildCount()
@@ -3,7 +3,6 @@ function Init()
m.top.observeField("focusedChild", "OnFocusChanged")
m.top.observeField("value", "OnValueChanged")
m.top.observeField("settings", "OnSettingsScreen")
m.keyboardWasClosedByButton = false
end function
function OnSettingsScreen()
@@ -45,15 +44,9 @@ function OnButtonSelected(event as object)
if buttonSelected = 0
m.top.value = keyboard.text
end if
m.keyboardWasClosedByButton = true
keyboard.close = true
end function
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)
end function