From 1b41a49fc55c1b6348f4bdcc59441a5c05a723ae Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 2 Jan 2009 02:48:06 +0000 Subject: Modified the way button highlights are processed when a widget is in dragging mode. This allows for example unhighlighting of a button when the user clicked on it but moved the mouse away. svn-id: r35666 --- gui/dialog.cpp | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'gui') diff --git a/gui/dialog.cpp b/gui/dialog.cpp index 9fd9d19fac..0cead248c9 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -250,9 +250,6 @@ void Dialog::handleKeyUp(Common::KeyState state) { void Dialog::handleMouseMoved(int x, int y, int button) { Widget *w; - //if (!button) - // _dragWidget = 0; - if (_focusedWidget && !_dragWidget) { w = _focusedWidget; int wx = w->getAbsX() - _x; @@ -271,27 +268,38 @@ void Dialog::handleMouseMoved(int x, int y, int button) { w->handleMouseLeft(button); } - w->handleMouseMoved(x - wx, y - wy, button); + if (w->getFlags() & WIDGET_TRACK_MOUSE) + w->handleMouseMoved(x - wx, y - wy, button); } - // While a "drag" is in process (i.e. mouse is moved while a button is pressed), - // only deal with the widget in which the click originated. - if (_dragWidget) - w = _dragWidget; - else + // We process mouseEntered/Left events if we don't have any + // currently active dragged widget or if the currently dragged widget + // does not want to be informed about the mouse mouse events. + if (!_dragWidget || !(_dragWidget->getFlags() & WIDGET_TRACK_MOUSE)) w = findWidget(x, y); + else + w = _dragWidget; if (_mouseWidget != w) { if (_mouseWidget) _mouseWidget->handleMouseLeft(button); + + // If we have a widget in drag mode we prevent mouseEntered + // events from being sent to other widgets. + if (_dragWidget && w != _dragWidget) + w = 0; + if (w) w->handleMouseEntered(button); _mouseWidget = w; } - if (w && (w->getFlags() & WIDGET_TRACK_MOUSE)) { + // We only sent mouse move events under the following conditions: + // 1) We have a widget in drag mode + // 2) The widget wants to track the mouse movement + w = _dragWidget; + if (w && (w->getFlags() & WIDGET_TRACK_MOUSE)) w->handleMouseMoved(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button); - } } void Dialog::handleTickle() { -- cgit v1.2.3