Merge pull request #284 from malikolivier/fix-build-with-ref

Fix toggling of MenuItem and Selectable with build_with_ref
This commit is contained in:
Joonas Javanainen 2019-12-08 00:49:47 +02:00 committed by GitHub
commit ccec55c10a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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