From 61a69153eec93f50acdc322a5f52406ac79fcb85 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 30 Mar 2011 13:35:11 +0000 Subject: Have ui::ListItem respect the disabled() state. --- src/ui/widget.cc | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/ui/widget.cc') diff --git a/src/ui/widget.cc b/src/ui/widget.cc index 37bde99..de18e6b 100644 --- a/src/ui/widget.cc +++ b/src/ui/widget.cc @@ -305,7 +305,7 @@ Widget *Widget::find_input_focus() for (Children::reverse_iterator rit = widget_children.rbegin(); rit != widget_children.rend(); ++rit) { Widget *w = (*rit); - if (w->visible() && w->widget_focus) { + if (w->visible() && w->enabled() && w->widget_focus) { Widget *f = w->find_input_focus(); if (f) return f; @@ -325,7 +325,7 @@ Widget *Widget::find_mouse_focus(const math::Vector2f & pos) // reverse-iterate children for (Children::reverse_iterator rit = widget_children.rbegin(); rit != widget_children.rend(); ++rit) { Widget *w = (*rit); - if (w->visible()) { + if (w->visible() && w->enabled()) { Widget *f = w->find_mouse_focus(pos - w->location()); if (f) return f; @@ -352,6 +352,9 @@ bool Widget::has_input_focus() const bool Widget::event_emit(Widget *sender, const Event event, void *data) // Unhandled events are sent to the parent widget { + if (disabled()) + return false; + if (on_emit(sender, event, data)) { return true; } else if (parent()) { @@ -367,12 +370,14 @@ bool Widget::event_key(const bool pressed, const int key, const unsigned int mod { bool handled = false; - if (pressed) { - handled = on_keypress(key, modifier); - } else { - handled = on_keyrelease(key, modifier); + if (enabled()) { + if (pressed) { + handled = on_keypress(key, modifier); + } else { + handled = on_keyrelease(key, modifier); + } } - + if (!handled && parent()) handled = parent()->event_key(pressed, key, modifier); @@ -381,6 +386,9 @@ bool Widget::event_key(const bool pressed, const int key, const unsigned int mod bool Widget::event_mouse(const math::Vector2f &cursor) { + if (disabled()) + return false; + math::Vector2f local_cursor = to_local_coords(cursor); bool handled = false; -- cgit v1.2.3