If I remove two children, focusedChild fires three times. Here is my example:
sub init()
m.top.overhang.showOptions = true
m.top.overhang.optionsAvailable = true
m.top.overhang.optionsText = "Delete"
m.categoriespanel = m.top.panelSet.createChild("CategoriesListPanel")
m.categoryinfopanel = m.top.panelSet.createChild("CategoryInfoPanel")
m.readContentTask = createObject("roSGNode", "ContentReader")
m.readContentTask.contenturi = "http://www.sdktestinglab.com/Tutorial/content/panelsetcontent.xml"
m.readContentTask.observeField("content", "setcategories")
m.readContentTask.control = "RUN"
m.categoriespanel.setFocus(true)
end sub
sub setcategories()
m.categoriespanel.list.content = m.readContentTask.content
m.categoriespanel.list.observeField("itemFocused", "show_example_preview")
m.categoryinfopanel.observeField("focusedChild", "view_example")
end sub
sub show_example_preview()
m.top.overhang.optionsAvailable = true
selected_example = m.categoriespanel.list.content.getChild(m.categoriespanel.list.itemFocused)
m.categoryinfopanel.description = selected_example.description
end sub
sub view_example()
if not m.top.panelSet.isGoingBack then
selected_example = m.categoriespanel.list.content.getChild(m.categoriespanel.list.itemFocused)
m.top.overhang.visible = false
m.top.panelset.visible = false
if (m.exampleviewerpanel <> invalid) then
m.top.removeChild(m.exampleviewerpanel)
m.exampleviewerpanel = invalid
end if
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
print "Create Poster"
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
m.exampleviewerpanel = invalid
m.exampleviewerpanel = createObject("roSGNode", "SomePoster")
m.top.appendChild(m.exampleviewerpanel)
m.exampleviewerpanel.setFocus(true)
else
m.top.overhang.visible = true
m.top.panelset.visible = true
m.categoriespanel.setFocus(true)
end if
end sub
function onKeyEvent(key as String, press as Boolean) as Boolean
if press then
if (key = "back") then
print "pressed back"
if (m.exampleviewerpanel <> invalid) then
m.top.removeChild(m.exampleviewerpanel)
m.exampleviewerpanel = invalid
m.top.overhang.visible = true
m.top.panelset.visible = true
m.categoriespanel.setFocus(true)
return true
end if
else if (key = "options") and (m.top.overhang.optionsAvailable) then
' ask if to delete or edit example
adialog = invalid
adialog = createObject("roSGNode", "Dialog")
adialog.title = "Delete ?"
adialog.buttons = ["Delete", "Cancel" ]
adialog.observeField("buttonSelected", "editdeleteexample")
m.top.dialog = adialog
return true
end if
end if
return false
end function
sub editdeleteexample()
selected_example = m.categoriespanel.list.content.getChild(m.categoriespanel.list.itemFocused)
if m.top.dialog.buttonSelected = 0 then ' delete
' do not delete here, ask for a pin first
m.categoriespanel.list.content.removeChild(selected_example)
end if
m.top.dialog.close = true
end sub
If you run it, press OK on the remote, you will get one message
print "Create Poster". If you press Options and delete an item and then press OK,
print "Create Poster" will show twice.
Is this a bug or I need to do something else when I try to delete a child from a ListPanel?
Here is the whole code in a zip:
https://www.dropbox.com/s/jzzw6efuls2a3lh/ListPanel-test.zip?dl=0EDIT: It seems that I don't even have to delete a child. Just refreshing the ListPanel, reloading the content will double/triple fire focusedChild event.
https://github.com/e1ioan/
http://rokucam.com