Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add radio buttons #29

Merged
merged 5 commits into from
Jul 23, 2023
Merged

Add radio buttons #29

merged 5 commits into from
Jul 23, 2023

Conversation

JD557
Copy link
Owner

@JD557 JD557 commented Jul 23, 2023

Adds a new radioButton component.

Also adds some new methods to Ref so that radio button groups are easier to define with local mutability, for example, like this:

val nextValue = currentValue.asRef { valueRef =>
  radioButton(id = "0", area = column(0), buttonIndex = 0, label = "0")(valueRef)
  radioButton(id = "1", area = column(1), buttonIndex = 1, label = "1")(valueRef)
  radioButton(id = "2", area = column(2), buttonIndex = 2, label = "2")(valueRef)
}

As opposed to

val nextValue = {
  val valueRef= Ref(currentValue)
  radioButton(id = "0", area = column(0), buttonIndex = 0, label = "0")(valueRef)
  radioButton(id = "1", area = column(1), buttonIndex = 1, label = "1")(valueRef)
  radioButton(id = "2", area = column(2), buttonIndex = 2, label = "2")(valueRef)
  valueRef.value
}

or

val nextValue = {
  var _nextValue = currentValue
  _nextValue = radioButton(id = "0", area = column(0), buttonIndex = 0, label = "0")(_nextValue)
  _nextValue = radioButton(id = "1", area = column(1), buttonIndex = 1, label = "1")(_nextValue)
  _nextValue = radioButton(id = "2", area = column(2), buttonIndex = 2, label = "2")(_nextValue)
  _nextValue
}

@JD557 JD557 added this to the 0.1.3 milestone Jul 23, 2023
@JD557 JD557 merged commit b7aa576 into master Jul 23, 2023
8 checks passed
@JD557 JD557 deleted the radio-buttons branch July 23, 2023 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant