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 Checkbox::set_text function. #1346

Merged
merged 2 commits into from
Oct 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ You can find its changes [documented below](#060---2020-06-01).
- TextBox supports vertical movement ([#1280] by [@cmyr])
- Widgets can specify a baseline, flex rows can align baselines ([#1295] by [@cmyr])
- `TextBox::with_text_color` and `TextBox::set_text_color` ([#1320] by [@cmyr])
- `Checkbox::set_text` to update the label. ([#1346] by [@finnerale])

### Changed

Expand Down Expand Up @@ -512,6 +513,7 @@ Last release without a changelog :(
[#1311]: https://github.com/linebender/druid/pull/1311
[#1320]: https://github.com/linebender/druid/pull/1320
[#1326]: https://github.com/linebender/druid/pull/1326
[#1346]: https://github.com/linebender/druid/pull/1346

[Unreleased]: https://github.com/linebender/druid/compare/v0.6.0...master
[0.6.0]: https://github.com/linebender/druid/compare/v0.5.0...v0.6.0
Expand Down
11 changes: 8 additions & 3 deletions druid/src/widget/checkbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,17 @@ pub struct Checkbox {
}

impl Checkbox {
/// Create a new `Checkbox` with a label.
pub fn new(label: impl Into<LabelText<bool>>) -> Checkbox {
/// Create a new `Checkbox` with a text label.
pub fn new(text: impl Into<LabelText<bool>>) -> Checkbox {
Checkbox {
child_label: Label::new(label),
child_label: Label::new(text),
}
}

/// Update the text label.
pub fn set_text(&mut self, label: impl Into<LabelText<bool>>) {
self.child_label.set_text(label);
}
}

impl Widget<bool> for Checkbox {
Expand Down