Skip to content

Commit

Permalink
Fix button behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
doyaGu committed Jul 9, 2024
1 parent 104898f commit 4a9638c
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/Bui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1227,13 +1227,14 @@ namespace Bui {

ImGui::BeginGroup();

ImGui::SetNextItemAllowOverlap();
ImGui::ItemSize(bb);
if (!ImGui::ItemAdd(bb, id))
return false;

bool hovered, held;
ImGui::ButtonBehavior(bb, id, &hovered, &held);
bool pressed = ImGui::ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_AllowOverlap | ImGuiButtonFlags_FlattenChildren);
if (pressed)
*v = !*v;

AddButtonImage(window->DrawList, bb, BUTTON_OPTION, hovered);

Expand Down Expand Up @@ -1290,13 +1291,12 @@ namespace Bui {

ImGui::BeginGroup();

ImGui::SetNextItemAllowOverlap();
ImGui::ItemSize(bb);
if (!ImGui::ItemAdd(bb, id))
return false;

bool hovered, held;
ImGui::ButtonBehavior(bb, id, &hovered, &held);
ImGui::ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_AllowOverlap | ImGuiButtonFlags_FlattenChildren);

AddButtonImage(window->DrawList, bb, BUTTON_OPTION, hovered);

Expand Down Expand Up @@ -1340,13 +1340,12 @@ namespace Bui {

ImGui::BeginGroup();

ImGui::SetNextItemAllowOverlap();
ImGui::ItemSize(bb);
if (!ImGui::ItemAdd(bb, id))
return false;

bool hovered, held;
ImGui::ButtonBehavior(bb, id, &hovered, &held);
ImGui::ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_AllowOverlap | ImGuiButtonFlags_FlattenChildren);

AddButtonImage(window->DrawList, bb, BUTTON_OPTION, hovered);

Expand Down Expand Up @@ -1390,13 +1389,12 @@ namespace Bui {

ImGui::BeginGroup();

ImGui::SetNextItemAllowOverlap();
ImGui::ItemSize(bb);
if (!ImGui::ItemAdd(bb, id))
return false;

bool hovered, held;
ImGui::ButtonBehavior(bb, id, &hovered, &held);
ImGui::ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_AllowOverlap | ImGuiButtonFlags_FlattenChildren);

AddButtonImage(window->DrawList, bb, BUTTON_OPTION, hovered);

Expand Down

0 comments on commit 4a9638c

Please sign in to comment.