EnTerr
9 years agoRoku Guru
RSG bug: node.addFields() mish-mash
"ifSGNodeField TFM" wrote:
addFields(aa as Object) as Boolean
Adds the field(s) and corresponding field value(s) defined as key-value pair(s) in the associative array aa to the subject node. The types of the added fields are determined by the values which correspond to the allowable types for an <interface> field. Returns true if the fields are successfully added, false otherwise.
Translation: if you feed addFields() an AA with field names and values for them, it will create fields with those names, guess the types by the values and set them to those values.
What happens if those fields already exist, one wonders? One imagines it could either
(a) work as setValues() for these (seems desirable) or
(b) throws an error.
Let's see:
BrightScript Debugger> o = createObject("roSgNode", "Label")
BrightScript Debugger> ? o.addFields({id: "movingLabel", width: 280, height: 60, text: "All The Best Videos!", horizAlign: "center", vertAlign: "center"})
true
Oh cool, so it returned True, everything went allright. Did it do (a), let's check (some properties omitted for brevity):
BrightScript Debugger> ? o
<Component: roSGNode> =
{
color: -572662273
height: 0
horizAlign: left
isTextEllipsized: false
text:
truncateOnDelimiter:
vertAlign: top
width: 0
focusedChild: <Component: roInvalid>
id:
height: 60
horizalign: center
id: movingLabel
text: All The Best Videos!
vertalign: center
width: 280
}
Turns out neither! RSG took (c) "the Road Not Taken", duplicated the fields and to add offense to injury, lied that everything is "halal" when it fact the node is in some kind of "haram" jumbled-up state!