Skip to content

Commit 33fd5d4

Browse files
committed
Refactor checkbox to use button
1 parent 8e794f6 commit 33fd5d4

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/tui.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,17 +2025,9 @@ impl<'a> Context<'a, '_> {
20252025
/// Creates a checkbox with the given text.
20262026
/// Returns true if the checkbox was activated.
20272027
pub fn checkbox(&mut self, classname: &'static str, text: &str, checked: &mut bool) -> bool {
2028-
self.styled_label_begin(classname);
2029-
self.attr_focusable();
2030-
if self.is_focused() {
2031-
self.attr_reverse();
2032-
}
2033-
self.styled_label_add_text(if *checked { "[🗹 " } else { "[☐ " });
2034-
self.styled_label_add_text(text);
2035-
self.styled_label_add_text("]");
2036-
self.styled_label_end();
2028+
let activated =
2029+
self.button(classname, text, ButtonStyle::default().checkmark((*checked).into()));
20372030

2038-
let activated = self.button_activated();
20392031
if activated {
20402032
*checked = !*checked;
20412033
}

0 commit comments

Comments
 (0)