optionsfield.monkey2 877 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. Namespace mojox
  2. Class OptionsField Extends DockingView
  3. Field CurrentChanged:Void()
  4. Method New( options:String[],current:Int=0 )
  5. _options=options
  6. _current=current
  7. _group=New CheckGroup
  8. _group.CheckedChanged+=Lambda()
  9. For Local i:=0 Until _checks.Length
  10. If _group.Checked=_checks[i]
  11. _current=i
  12. CurrentChanged()
  13. Return
  14. Endif
  15. Next
  16. End
  17. _checks=New CheckButton[options.Length]
  18. For Local i:=0 Until options.Length
  19. _checks[i]=New CheckButton( _options[i],,_group )
  20. AddView( _checks[i],"left" )
  21. Next
  22. _checks[_current].Checked=True
  23. End
  24. Property Current:Int()
  25. Return _current
  26. Setter( current:Int )
  27. _current=current
  28. _checks[_current].Checked=True
  29. End
  30. Private
  31. Field _options:String[]
  32. Field _current:Int
  33. Field _group:CheckGroup
  34. Field _checks:CheckButton[]
  35. End