Ok, I have a very simple PosterGrid:
<PosterGrid
id="main_menu"
translation="[32,32]"
basePosterSize="[640,270]"
itemSpacing="[32,32]"
numColumns="2"
numRows="2">
<ContentNode role = "content" >
<ContentNode id="node_1" hdgridposterurl="pkg:/images/image_1.png" focusable="true"/>
<ContentNode id="node_2" hdgridposterurl="pkg:/images/image_2.png" focusable="true"/>
<ContentNode id="node_3" hdgridposterurl="pkg:/images/image_3.png" focusable="true"/>
<ContentNode id="node_4" hdgridposterurl="pkg:/images/image_4.png" focusable="true"/>
</ContentNode>
</PosterGrid>
What I want to do is process the OK key and get which node was clicked.
I read about roSGNodeEvent but I can't find any example on how to use this, documentation is very lacking. I have:
FUNCTION onKeyEvent(key as String, press as Boolean) as Boolean
IF (press = false) THEN
' What do i put here? is there a way to access the roSGNodeEvent here?
I want something that returns "node_X" depending on which Node the OK button was clicked.
END IF
END FUNCTION
In general, you don't process key presses, you set up observers on events.
Sub init()
m.menu_grid = m.top.findNode("menu_grid")
m.menu_grid.observeField("itemSelected","onPosterSelected")
...
End Sub
Sub onPosterSelected(obj as Object)
' m.menu_grid.itemSelected has the index number of the poster selected
' as does obj.GetData()
' do your stuff here
End Sub
This is a core concept of Scene Graph that you'll need to understand.
In general, you don't process key presses, you set up observers on events.
Sub init()
m.menu_grid = m.top.findNode("menu_grid")
m.menu_grid.observeField("itemSelected","onPosterSelected")
...
End Sub
Sub onPosterSelected(obj as Object)
' m.menu_grid.itemSelected has the index number of the poster selected
' as does obj.GetData()
' do your stuff here
End Sub
This is a core concept of Scene Graph that you'll need to understand.
Awesome! This is exactly what I needed, thanks a lot.
To obtain information on which node triggered an event, you would typically cutting need access to the specific system or software that handles event tracking and logging.