I've been trying to create an Option dialog that isn't limited to two or three choices (Option.YesNo or Option.YesNoCancel), but I've been unable to find a way to use anything but these built-in options. Specifically, the following refuses to accept anything that I can put for optionType:
object Choices extends Enumeration {
type Choice = Value
val red, yellow, green, blue = Value
}
val options = List("Red", "Yellow", "Green", "Blue")
label.text = showOptions(null,
"What is your favorite color?",
"Color preference",
optionType = Choices.Value,
entries = options,
initial = 2) match {
case Choice.red => "Red"
case Choice.yellow => "Yellow"
case Choice.green => "Green"
case Choice.blue => "Blue"
case _ => "Some other color"
}
Yes, it's one of the many design bugs in Scala-Swing. You can write your own
showOptions
method:If you want to pass in strings instead, change to
entries: Seq[Any]
,initial: Int
, useentries(initial)
in the call, and just returnr
ofInt
.