In the BB10 Cascades development environment, you can use the SegmentedControl control to present a horizontally placed single-choice component. In BB10 Cascades, you can use the Object id. the selectedValue () method is used to obtain the selected options.
The official example is as follows. However, this example runs successfully only on BB10 Cascades Beta2. If you use the following code on BB10 Cascades Beta3, the following error will be reported:
TypeError: Result of expression 'segmented1. selectedValue '[1] is not a function.
To solve the problem, replace "Object id. selectedValue ()" with "selectedValue", because in onSelectedIndexChanged, selectedValue directly gives the selected content.
The following error code is displayed:
[Javascript]
SegmentedControl {
Id: segmented1
Option {
Id: option1
Text: "option 1"
Value: "option1"
Selected: true
}
Option {
Id: option2
Text: "option 2"
Value: "option2"
}
Option {
Id: option3
Text: "option 3"
Value: "option3"
}
OnSelectedIndexChanged :{
Var value = segmented1.selectedValue ()
Console. debug ("Selected value:" + value );
}
}
The following is the code that can be run on Cascades Beta3. Pay attention to the row selectedValue.
[Javascript]
SegmentedControl {
Id: segmented1
Option {
Id: option1
Text: "option 1"
Value: "option1"
Selected: true
}
Option {
Id: option2
Text: "option 2"
Value: "option2"
}
Option {
Id: option3
Text: "option 3"
Value: "option3"
}
OnSelectedIndexChanged :{
Var value = selectedValue;
Console. debug ("Selected value:" + value );
}
}