Forum Discussion

FCF-Ben's avatar
FCF-Ben
Reel Rookie
4 years ago
Solved

Not getting observeField (or observeFieldScoped) to firing callback

Trying to mash together two (or three) examples I found, to create a dialog that will fire if you press back arrow when on the home screen (or technically the last screen in the stack array).  So ...
  • renojim's avatar
    4 years ago

    If the code you've shown is a copy and paste then you have a typo:

     

    m.exitDialog.observeField("buttonSeleted", "onButtonSelected")

    Should be buttonSelected.

     

    But that's not the only problem.  Even if you fix the line, add a print in front of it and I bet it prints out false meaning the statement failed and your observer will never be called.

     

    print m.exitDialog.observeField("buttonSelected", "onButtonSelected")

    That "buttonSelected" needs to be attached to a component.  I'm not sure how to accomplish that; I've only ever done it via an interface alias in the XML file for the node/group/component or whatever it's called.

     

    XML:

    <interface>
    <field id="button_selected"
    type="assocarray"
    alias="dialog.buttonSelected"
    />
    </interface>
    <children>
    <Dialog
    id="dialog"
    />
    </children>
    </component>

    BRS:

    print m.top.observeField("button_selected", "onButtonSelected")

    I tried a quick test trying to add it to the code you have, but I couldn't come up with the right way to specify it or I had some other problem with the code since it's not complete.

     

    As for observeField vs observeFieldScoped, I've wondered the same thing, but I've never taken the time to investigate it.

    I have to include my standard caveat:  As I've stated many times, I'm not the person to ask about scene graph as I absolutely hate it.  Maybe if I wasted took the time to learn more than the bare minimum I wouldn't hate it so much, but I don't see that ever happening.