diff --git a/src/ftxui/component/checkbox.cpp b/src/ftxui/component/checkbox.cpp index ebfa46d8..3d95edb3 100644 --- a/src/ftxui/component/checkbox.cpp +++ b/src/ftxui/component/checkbox.cpp @@ -70,17 +70,25 @@ class CheckboxBase : public ComponentBase, public CheckboxOption { } if (event.mouse().button == Mouse::Left && - event.mouse().motion == Mouse::Pressed) { + event.mouse().motion == Mouse::Pressed && + isMousePressed == false) { *checked = !*checked; + isMousePressed = true; on_change(); return true; } + if (event.mouse().button == Mouse::Left && + event.mouse().motion == Mouse::Released) { + isMousePressed = false; + } + return false; } bool Focusable() const final { return true; } + bool isMousePressed = false; bool hovered_ = false; Box box_; };