Focus and unfocus search box

This commit is contained in:
Nick Bisby 2019-03-14 16:50:42 -05:00
parent 187a3b6d5a
commit a2f4df9884
No known key found for this signature in database
GPG Key ID: F6E0C4E6D0B5EB36
3 changed files with 37 additions and 1 deletions

View File

@ -87,6 +87,20 @@
end for
return data
end function
function onKeyEvent(key as string, press as boolean) as boolean
if not press then return false
if key = "down" and (m.top.itemFocused + 1) = m.top.content.getChildCount()
search = m.top.getScene().findNode("search")
search.setFocus(true)
search.findNode("search-input").setFocus(true)
search.findNode("search-input").active = true
return true
end if
return false
end function
]]>
</script>
</component>

View File

@ -2,8 +2,11 @@
<component name="SearchBox" extends="LayoutGroup">
<children>
<Label text="Search" />
<TextEditBox id="search-input" />
<TextEditBox id="search-input" width="800" maxTextLength="75" />
</children>
<interface>
<field id="escape" type="boolean" alwaysNotify="true" />
</interface>
<script type="text/brightscript">
<![CDATA[
sub init()
@ -14,6 +17,20 @@
m.top.vertAlignment = "top"
end sub
function onKeyEvent(key as string, press as boolean) as boolean
if not press then return false
if key = "OK"
' Make a Keyboard Dialog here
print "KEYBOARD"
else if key = "up"
m.top.findNode("search-input").active = false
m.top.escape = true
return true
end if
return false
end function
]]>
</script>
</component>

View File

@ -93,10 +93,15 @@ sub ShowLibrarySelect()
library.observeField("itemSelected", port)
search = scene.findNode("search")
search.observeField("escape", port)
while(true)
msg = wait(0, port)
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then
exit while
else if nodeEventQ(msg, "escape") and msg.getNode() = "search"
library.setFocus(true)
else if nodeEventQ(msg, "itemSelected")
target = getMsgRowTarget(msg)
if target.libraryType = "movies"