Allow widget::find_at() to return a scrollbar container
If the pointer wasn't on top of any widget within a scrollbar container, when GUI2 queried the widget on which a UI event occurred, the answer was "no widget" and the whole event was discarded. That was problematic if the player was trying to scroll. It is desired that scrolling is possible even if the pointer isn't on a widget (as long as it's somewhere within the scrollbar container). Now the query will return "scrollbar container" and dispatch the event to it. That allows the player to scroll anywhere within a scrollbar container. Also, now the GUI2 event chain includes the target widget itself, not only its ancestors. Fixes #1632.
This commit is contained in:
parent
5ba35e42b1
commit
315f8496b6
2 changed files with 13 additions and 5 deletions
|
@ -306,12 +306,12 @@ build_event_chain(const ui_event event, widget* dispatcher, widget* w)
|
|||
std::vector<std::pair<widget*, ui_event>> result;
|
||||
|
||||
while(w != dispatcher) {
|
||||
w = w->parent();
|
||||
assert(w);
|
||||
|
||||
if(w->has_event(event, dispatcher::event_queue_type(dispatcher::pre | dispatcher::post))) {
|
||||
result.emplace_back(w, event);
|
||||
}
|
||||
|
||||
w = w->parent();
|
||||
assert(w);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -516,15 +516,23 @@ unsigned scrollbar_container::get_state() const
|
|||
widget* scrollbar_container::find_at(const point& coordinate,
|
||||
const bool must_be_active)
|
||||
{
|
||||
return scrollbar_container_implementation::find_at<widget>(
|
||||
widget* w = scrollbar_container_implementation::find_at<widget>(
|
||||
*this, coordinate, must_be_active);
|
||||
if(w == nullptr) {
|
||||
w = widget::find_at(coordinate, must_be_active);
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
const widget* scrollbar_container::find_at(const point& coordinate,
|
||||
const bool must_be_active) const
|
||||
{
|
||||
return scrollbar_container_implementation::find_at<const widget>(
|
||||
const widget* w = scrollbar_container_implementation::find_at<const widget>(
|
||||
*this, coordinate, must_be_active);
|
||||
if(w == nullptr) {
|
||||
w = widget::find_at(coordinate, must_be_active);
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
widget* scrollbar_container::find(const std::string& id,
|
||||
|
|
Loading…
Add table
Reference in a new issue