mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-07-09 02:41:15 +08:00
Prevent drag spamming buttons
This commit is contained in:
parent
e8589dd533
commit
8ee2f12ef9
@ -50,6 +50,11 @@ class ButtonBase : public ComponentBase, public ButtonOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto focus_management = focused ? focus : active ? select : nothing;
|
auto focus_management = focused ? focus : active ? select : nothing;
|
||||||
|
|
||||||
|
if (focus_management == nothing) {
|
||||||
|
isMousePressed = false;
|
||||||
|
}
|
||||||
|
|
||||||
const EntryState state = {
|
const EntryState state = {
|
||||||
*label,
|
*label,
|
||||||
false,
|
false,
|
||||||
@ -125,9 +130,16 @@ class ButtonBase : public ComponentBase, public ButtonOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event.mouse().button == Mouse::Left &&
|
if (event.mouse().button == Mouse::Left &&
|
||||||
event.mouse().motion == Mouse::Pressed) {
|
event.mouse().motion == Mouse::Pressed && isMousePressed == false) {
|
||||||
TakeFocus();
|
TakeFocus();
|
||||||
OnClick();
|
OnClick();
|
||||||
|
isMousePressed = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(event.mouse().button == Mouse::Left &&
|
||||||
|
event.mouse().motion == Mouse::Released) {
|
||||||
|
isMousePressed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,6 +149,7 @@ class ButtonBase : public ComponentBase, public ButtonOption {
|
|||||||
bool Focusable() const final { return true; }
|
bool Focusable() const final { return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool isMousePressed = false;
|
||||||
bool mouse_hover_ = false;
|
bool mouse_hover_ = false;
|
||||||
Box box_;
|
Box box_;
|
||||||
ButtonOption option_;
|
ButtonOption option_;
|
||||||
|
Loading…
Reference in New Issue
Block a user