mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-14 23:18:28 +00:00
Fix toggling of MenuItem and Selectable with build_with_ref
Selectable or MenuItem should be toggled on click when called with build_with_ref. This is the behavior that is done in ImGui when `bool ImGui::MenuItem(const char* label, const char* shortcut, bool*p_selected, bool enabled)` is called.
This commit is contained in:
parent
ffff82d5e4
commit
55a8f28e0a
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user