components_ItemGrid_Alpha.bs
sub init()
m.top.setFocus(false)
m.alphaText = m.top.findNode("alphaText")
m.alphaMenu = m.top.findNode("alphaMenu")
m.alphaMenu.setFocus(false)
applyTheme()
end sub
sub applyTheme()
constants = m.global.constants
' show mic icon above alpha menu if remote supports voice commands
if m.global.device.hasVoiceRemote
alphaMic = m.top.findNode("alphaMic")
alphaMic.blendColor = constants.colorTextSecondary
alphaMic.visible = true
end if
' font sizes
m.alphaMenu.focusedFont.size = constants.fontSizeSmaller
m.alphaMenu.font.size = constants.fontSizeSmaller
' font colors
m.alphaMenu.focusedColor = constants.colorTextPrimary
m.alphaMenu.color = constants.colorTextSecondary
' focus 9patch and color
m.alphaMenu.focusBitmapUri = "pkg:/images/9patch/border-6px.9.png"
m.alphaMenu.focusBitmapBlendColor = constants.colorPrimary
' focus footprint 9patch
m.alphaMenu.focusFootprintBitmapUri = "pkg:/images/1px-transparent.png"
end sub
function onKeyEvent(key as string, press as boolean) as boolean
if not press then return false
if not m.alphaMenu.isInFocusChain() then return false
if key = "OK"
child = m.alphaText.getChild(m.alphaMenu.itemFocused)
m.top.letterSelected = child.title
return true
end if
if key = "up"
if m.alphaMenu.itemFocused = 0
m.alphaMenu.jumpToItem = m.alphaMenu.numRows - 1
return true
end if
end if
if key = "down"
if m.alphaMenu.itemFocused = m.alphaMenu.numRows - 1
m.alphaMenu.jumpToItem = 0
return true
end if
end if
return false
end function