Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ioan
Roku Guru

I think I found a bug: After removing a child from a ListPanel, focusedChild fires twice.

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=0

EDIT: 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
0 Kudos
4 REPLIES 4
EnTerr
Roku Guru

Re: I think I found a bug: After removing a child from a ListPanel, focusedChild fires twice.

"ioan" wrote:
EDIT: 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.

is that bad?
i.e. how is that harmful to you
0 Kudos
ioan
Roku Guru

Re: I think I found a bug: After removing a child from a ListPanel, focusedChild fires twice.

"EnTerr" wrote:
"ioan" wrote:
EDIT: 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.

is that bad?
i.e. how is that harmful to you



m.exampleviewerpanel = createObject("roSGNode", "SomePoster")


The m.exampleviewerpanel that I create starts a Task on it that receives stream from a camera... so the Task gets created twice, or 3 times... and only the last one terminates when I signal it to terminate. Of course I "fixed it" by making sure that I only create the m.exampleviewerpanel once and ignore the other calls... but it should be called just once, don't you think?
https://github.com/e1ioan/
http://rokucam.com
0 Kudos
EnTerr
Roku Guru

Re: I think I found a bug: After removing a child from a ListPanel, focusedChild fires twice.

"ioan" wrote:
... I "fixed it" by making sure that I only create the m.exampleviewerpanel once and ignore the other calls... but it should be called just once, don't you think?

When dealing with RSG, seems to me that the less one thinks or assumes - the better.

Off topic: 
...
I also tried m.save.checkedlist.Append(a) and to push each element separately, but I always get error. What's the right way to do this?

The right way is to open a new topic on this one :mrgreen: - after all we may keep tackling the double-event here.
Could be couple of issues, since i saw a peripheral one.
0 Kudos
ioan
Roku Guru

Re: I think I found a bug: After removing a child from a ListPanel, focusedChild fires twice.

"EnTerr" wrote:

The right way is to open a new topic on this one :mrgreen: - after all we may keep tackling the double-event here.
Could be couple of issues, since i saw a peripheral one.


Edited my prev. comment and got rid of the off-topic question and posted it in a new thread.
https://github.com/e1ioan/
http://rokucam.com
0 Kudos