From 398f3df8af02047a76ab7172c69d93313250260c Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 29 Jan 2012 13:51:31 +0000 Subject: FS#80 Have mouse focus stick to the widget when the mouse button is down. --- src/ui/widget.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/ui/widget.cc') diff --git a/src/ui/widget.cc b/src/ui/widget.cc index 6d0fb84..7cde03b 100644 --- a/src/ui/widget.cc +++ b/src/ui/widget.cc @@ -366,6 +366,24 @@ Widget *Widget::find_input_focus() return this; } +Widget *Widget::find_visible_child(const Widget *widget) +{ + if (!visible()) + return 0; + + if (this == widget) + return this; + + // search in reverse drawing order + for (Children::reverse_iterator rit = widget_children.rbegin(); rit != widget_children.rend(); ++rit) { + Widget *f = (*rit)->find_visible_child(widget); + if (f) { + return f; + } + } + return 0; +} + Widget *Widget::find_mouse_focus(const math::Vector2f & pos) { // this widget is not visible -- cgit v1.2.3