Skip to content

Commit

Permalink
feat(imgui): update toggleRaw() to update value earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Aug 13, 2019
1 parent d06a235 commit 21ba39d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/imgui/src/components/toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ export const toggleRaw = (
}
const focused = gui.requestFocus(id);
let changed = !gui.buttons && gui.hotID === id && gui.activeID === id;
const v = val[i];
focused && (changed = handleButtonKeys(gui) || changed);
changed && (val[i] = !val[i]);
box.attribs = {
fill: v ? gui.fgColor(hover) : gui.bgColor(hover),
fill: val[i] ? gui.fgColor(hover) : gui.bgColor(hover),
stroke: gui.focusColor(id)
};
gui.add(box);
Expand All @@ -84,8 +85,6 @@ export const toggleRaw = (
label
)
);
focused && (changed = handleButtonKeys(gui) || changed);
changed && (val[i] = !v);
gui.lastID = id;
return changed;
};

0 comments on commit 21ba39d

Please sign in to comment.