Added anti drag feature to checkboxes

This commit is contained in:
Clement Roblot 2023-10-24 14:47:39 +07:00 committed by ArthurSonzogni
parent 785bada114
commit de686acd69
No known key found for this signature in database
GPG Key ID: 41D98248C074CD6C

View File

@ -70,17 +70,25 @@ class CheckboxBase : public ComponentBase, public CheckboxOption {
} }
if (event.mouse().button == Mouse::Left && if (event.mouse().button == Mouse::Left &&
event.mouse().motion == Mouse::Pressed) { event.mouse().motion == Mouse::Pressed &&
isMousePressed == false) {
*checked = !*checked; *checked = !*checked;
isMousePressed = true;
on_change(); on_change();
return true; return true;
} }
if (event.mouse().button == Mouse::Left &&
event.mouse().motion == Mouse::Released) {
isMousePressed = false;
}
return false; return false;
} }
bool Focusable() const final { return true; } bool Focusable() const final { return true; }
bool isMousePressed = false;
bool hovered_ = false; bool hovered_ = false;
Box box_; Box box_;
}; };