From 3ee941b5196cd9328f8e6d5de8fb0aeeae9e39f1 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Fri, 18 Jan 2013 19:40:54 +0100 Subject: menu: add get_component_at to get component This is the basis for mouse focus handling. --- src/menu/container.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/menu/container.cpp') diff --git a/src/menu/container.cpp b/src/menu/container.cpp index 31155e3c..fb13d398 100644 --- a/src/menu/container.cpp +++ b/src/menu/container.cpp @@ -144,4 +144,25 @@ namespace usdx DrawableControl::set_size(width, height); recalculate_window_coords(); } + + DrawableControl* Container::get_component_at(const Point& p) + { + if (!get_absolut_rect().is_in(p)) + return NULL; + + for (std::list::iterator next = controls.begin(), it = next++; + it != controls.end(); it = next++) { + + DrawableControl* c = (*it)->get_component_at(p); + if (c != NULL) { + return c; + } + } + + if (frame) { + return frame->get_component_at(p); + } + + return this; + } }; -- cgit v1.2.3