I also downloaded the simpleRowList.zip http://sdkdocs.roku.com/display/sdkdoc/RowList and while the nodes render, the key presses are not handled. It appears that the setFocus is being set inside the init() function but it does not fire for some reason.
Any help would be appreciated.
CustomMarkUpGrid.xml
Code: Select all
<?xml version="1.0" encoding="utf-8" ?>
<component name="CustomMarkupGrid" extends="MarkupGrid" >
<script type="text/brightscript" >
<![CDATA[
function init()
print "in markup grid init()"
m.top.itemComponentName = "SimpleGridItem"
m.top.numRows = 3
m.top.numColumns = 1
m.top.itemSize = "[200, 200]"
m.top.itemSpacing = "[4,6]"
m.top.vertFocusAnimationStyle = "floatingFocus"
data = CreateObject("roSGNode", "ContentNode")
item = data.CreateChild("ContentNode")
item.HDPOSTERURL = "http://orig03.deviantart.net/e9be/f/2009/079/e/d/aimp2_icon_128x128_by_vicing.png"
item.GOTITEMCONTENT = false
item.PRICE = "25.99"
item.width = "200"
item.height = "200"
item = data.CreateChild("ContentNode")
item.HDPOSTERURL = "https://upload.wikimedia.org/wikipedia/commons/9/99/Opml-icon-128x128.png"
item.GOTITEMCONTENT = false
item.PRICE = "19.99"
item.width = "200"
item.height = "200"
item = data.CreateChild("ContentNode")
item.HDPOSTERURL = "http://orig03.deviantart.net/e9be/f/2009/079/e/d/aimp2_icon_128x128_by_vicing.png"
item.GOTITEMCONTENT = false
item.PRICE = "19.99"
item.width = "300"
item.height = "300"
m.top.content = data
m.top.visible = true
m.top.SetFocus(true)
print "has focus:"
print m.top.hasFocus()
m.top.ObserveField("itemSelected", "onItemSelected")
m.top.ObserveField("itemFocused", "onitemFocused")
end function
function onitemFocused() as void
print "item itemFocused"
print m.top.itemFocused
end function
function onItemSelected() as void
print "item selected"
print m.top.itemSelected
end function
function onKeyEvent(key as String, press as Boolean) as Boolean
handled = false
print "Channel Zapper: " + key
if press
if key = "left"
print "key press left"
end if
end if
return handled
end function
]]>
</script>
</component>
SimpleGridItem.xml
Code: Select all
<?xml version="1.0" encoding="utf-8" ?>
<component name="SimpleGridItem" extends="Group">
<interface>
<field id="width" type="float" onChange="widthChanged"/>
<field id="height" type="float" onChange="heightChanged"/>
<field id="itemContent" type="node" onChange="itemContentChanged"/>
</interface>
<script type="text/brightscript" >
<![CDATA[
function itemContentChanged()
print "itemContentChanged"
m.gridPoster.uri = m.top.itemContent.HDPOSTERURL
print "m.top.itemContent.HDPOSTERURL"
print m.top.itemContent.PRICE
print m.top.itemContent.HDPOSTERURL
if m.top.itemContent.GOTITEMCONTENT
m.priceBox.visible = false
m.priceLabel.visible = false
m.ownedIcon.visible = true
else
m.priceLabel.text = m.top.itemContent.PRICE
m.priceBox.visible = true
m.priceLabel.visible = true
m.ownedIcon.visible = false
end if
updateLayout()
end function
function widthChanged()
updateLayout()
end function
function heightChanged()
updateLayout()
end function
function updateLayout()
print "updateLayout"
if m.top.height > 0 and m.top.width > 0
print "got inside updateLayout"
posterSize = m.top.height
m.gridPoster.width = m.top.width
m.gridPoster.height = m.top.height
' position the ownedIcon in the bottom/right corner
m.ownedIcon.translation = [ m.top.width - m.ownedIcon.bitmapWidth, m.top.height - m.ownedIcon.bitmapHeight ]
m.priceBox.width = m.top.width
m.priceBox.height = m.ownedIcon.bitmapHeight
m.priceBox.translation = [ 0, m.top.height - m.priceBox.height ]
m.priceLabel.width = m.top.width
m.priceLabel.height = m.priceBox.height
m.priceLabel.vertAlign = "center"
m.priceLabel.horizAlign = "center"
m.priceLabel.translation = m.priceBox.translation
end if
end function
function init()
m.gridPoster = m.top.findNode("gridPoster")
m.priceBox = m.top.findNode("priceBox")
m.priceLabel = m.top.findNode("priceLabel")
m.ownedIcon = m.top.findNode("ownedIcon")
m.ownedIcon.loadSync = true
m.ownedIcon.uri = "http://arts.dartmouth.edu/assets/green-check.png"
end function
]]>
</script>
<children>
<Poster id="gridPoster" />
<Rectangle id="priceBox" color="0x00000080" />
<Label id="priceLabel" text="text here" />
<Poster id="ownedIcon" />
</children>
</component>