components_ui_dropdown_JRDropdownItem.bs
sub init()
m.itemBackground = m.top.findNode("itemBackground")
m.itemBorder = m.top.findNode("itemBorder")
m.itemLabel = m.top.findNode("itemLabel")
' Default visual state: unfocused
m.itemLabel.color = m.global.constants.colorTextPrimary
' Apply initial sizing
onSizeChanged()
end sub
sub onTextChanged()
m.itemLabel.text = m.top.text
end sub
sub onSizeChanged()
itemWidth = m.top.itemWidth
itemHeight = m.top.itemHeight
padding = 20
' Size the 9-patch background and border to fill the item area
m.itemBackground.width = itemWidth
m.itemBackground.height = itemHeight
m.itemBorder.width = itemWidth
m.itemBorder.height = itemHeight
m.itemLabel.width = itemWidth - (padding * 2)
m.itemLabel.height = itemHeight
m.itemLabel.translation = [padding, 0]
end sub
' Updates visual state based on virtual isFocused and isSelected fields.
' Focused state uses button-like styling: 9-patch border + background (same as TextButton).
' JRDropdown manages focus externally — this item never receives real Roku focus.
sub onFocusStateChanged()
constants = m.global.constants
if m.top.isFocused
' Button-like focus: show border in primary color, background in secondary
m.itemBorder.blendColor = constants.colorPrimary
m.itemBackground.blendColor = constants.colorBackgroundSecondary
m.itemBorder.visible = true
m.itemBackground.visible = true
m.itemLabel.color = constants.colorTextPrimary
else
' Hide button visuals when unfocused
m.itemBorder.visible = false
m.itemBackground.visible = false
if m.top.isSelected
m.itemLabel.color = constants.colorSecondary
else
m.itemLabel.color = constants.colorTextPrimary
end if
end if
end sub