Fix scroller handling mouse click

This commit is contained in:
Nikita Lisitsa 2022-03-03 17:33:53 +03:00
parent a14f936cf0
commit 343a0aed78

View file

@ -107,26 +107,28 @@ namespace psemek::ui
if (e.button != mouse_button::left) if (e.button != mouse_button::left)
return false; return false;
bool result = false;
if (horizontal_scroll()) if (horizontal_scroll())
{ {
switch (horizontal_state_) switch (horizontal_state_)
{ {
case state_t::normal: case state_t::normal:
return false; break;
case state_t::mouseover: case state_t::mouseover:
if (e.down) if (e.down)
{ {
horizontal_state_ = state_t::mousedown; horizontal_state_ = state_t::mousedown;
return true; result = true;
} }
return false; break;
case state_t::mousedown: case state_t::mousedown:
if (!e.down) if (!e.down)
{ {
horizontal_state_ = state_t::mouseover; horizontal_state_ = state_t::mouseover;
return true; result = true;
} }
return false; break;
} }
} }
@ -135,25 +137,25 @@ namespace psemek::ui
switch (vertical_state_) switch (vertical_state_)
{ {
case state_t::normal: case state_t::normal:
return false; break;
case state_t::mouseover: case state_t::mouseover:
if (e.down) if (e.down)
{ {
vertical_state_ = state_t::mousedown; vertical_state_ = state_t::mousedown;
return true; result = true;
} }
return false; break;
case state_t::mousedown: case state_t::mousedown:
if (!e.down) if (!e.down)
{ {
vertical_state_ = state_t::mouseover; vertical_state_ = state_t::mouseover;
return true; result = true;
} }
return false; break;
} }
} }
return false; return result;
} }
bool scroller::on_event(mouse_wheel const & e) bool scroller::on_event(mouse_wheel const & e)