'Parameters: SelectedIndex as Int, 2 or more RadioButtons or ToggleButtons
'DesignerScript: {Class}.SetToggleGroup(0,RadioButton1,Radiobutton2)
Public Sub SetToggleGroup(DesignerArgs As DesignerArgs)
Dim SelectedIndex As Int = DesignerArgs.Arguments.Get(0)
Dim RBG As JavaObject
RBG.InitializeNewInstance("javafx.scene.control.ToggleGroup",Null)
For i = 1 To DesignerArgs.Arguments.Size - 1
Dim RB As JavaObject = DesignerArgs.GetViewFromArgs(i)
RB.RunMethod("setToggleGroup",Array(RBG))
CSSUtils.SetStyleProperty(RB, "-fx-border-color", "#d9dee5")
If i = 1 Then
CSSUtils.SetStyleProperty(RB, "-fx-background-radius", "5 0 0 5")
CSSUtils.SetStyleProperty(RB, "-fx-border-radius", "5 0 0 5")
CSSUtils.SetStyleProperty(RB, "-fx-border-width", "1 0 1 1")
Else If i = DesignerArgs.Arguments.Size - 1 Then
CSSUtils.SetStyleProperty(RB, "-fx-background-radius", "0 5 5 0")
CSSUtils.SetStyleProperty(RB, "-fx-border-radius", "0 5 5 0")
CSSUtils.SetStyleProperty(RB, "-fx-border-width", "1")
Else
CSSUtils.SetStyleProperty(RB, "-fx-border-width", "1 0 1 1")
CSSUtils.SetStyleProperty(RB, "-fx-border-radius", "0")
End If
Next
If SelectedIndex < 0 Or SelectedIndex > DesignerArgs.Arguments.Size - 2 Then
SelectedIndex = 0
End If
DesignerArgs.GetViewFromArgs(SelectedIndex + 1).As(JavaObject).RunMethod("setSelected",Array(True))
End Sub