Fix default ui::window impl event handling

This commit is contained in:
Nikita Lisitsa 2022-12-18 21:55:23 +03:00
parent 1c9fb28ebf
commit 9ab72a7c1a

View file

@ -311,19 +311,33 @@ namespace psemek::ui
bool on_event(mouse_click const & e) override bool on_event(mouse_click const & e) override
{ {
if (!mouse_ || !shape().contains(geom::cast<float>(*mouse_))) if (!mouse_)
return false; return false;
if (e.button == mouse_button::left && mouse_) if (e.button == mouse_button::left && mouse_)
{ {
if (e.down) if (e.down && shape().contains(geom::cast<float>(*mouse_)))
{
drag_ = *mouse_; drag_ = *mouse_;
else
drag_ = std::nullopt;
}
return true; return true;
} }
if (!e.down && drag_)
{
drag_ = std::nullopt;
return true;
}
}
if (e.button == mouse_button::left && mouse_)
{
if (shape().contains(geom::cast<float>(*mouse_)))
return true;
}
return false;
}
bool on_event(mouse_wheel const &) override bool on_event(mouse_wheel const &) override
{ {
return mouse_ && shape().contains(geom::cast<float>(*mouse_)); return mouse_ && shape().contains(geom::cast<float>(*mouse_));