diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index e16f90e..a97ccec 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -14,6 +14,11 @@ - Various things that were deprecated in imgui-rs 0.2.0 +### Fixed + +- Fix toggling behavior on using `MenuItem::build_with_ref` and + `Selectable::build_with_ref`. + ## [0.2.1] - 2019-09-09 ### Fixed diff --git a/src/widget/menu.rs b/src/widget/menu.rs index 9673dca..883e7cf 100644 --- a/src/widget/menu.rs +++ b/src/widget/menu.rs @@ -143,7 +143,7 @@ impl<'a> MenuItem<'a> { /// Builds the menu item using a mutable reference to selected state. pub fn build_with_ref(self, ui: &Ui, selected: &mut bool) -> bool { if self.selected(*selected).build(ui) { - *selected = true; + *selected = !*selected; true } else { false diff --git a/src/widget/selectable.rs b/src/widget/selectable.rs index c790823..9f3ce39 100644 --- a/src/widget/selectable.rs +++ b/src/widget/selectable.rs @@ -123,7 +123,7 @@ impl<'a> Selectable<'a> { /// Builds the selectable using a mutable reference to selected state. pub fn build_with_ref(self, ui: &Ui, selected: &mut bool) -> bool { if self.selected(*selected).build(ui) { - *selected = true; + *selected = !*selected; true } else { false