aboutsummaryrefslogtreecommitdiff
path: root/gui/dialog.cpp
diff options
context:
space:
mode:
authorMax Horn2004-12-25 23:20:37 +0000
committerMax Horn2004-12-25 23:20:37 +0000
commit71051f551e831191f18734a2902559f33346d0e0 (patch)
treedcd59cbd158e4e042a9dd28552011b883fde5c54 /gui/dialog.cpp
parent509f1b040f3877638d009467bcbf6977e3c62917 (diff)
downloadscummvm-rg350-71051f551e831191f18734a2902559f33346d0e0.tar.gz
scummvm-rg350-71051f551e831191f18734a2902559f33346d0e0.tar.bz2
scummvm-rg350-71051f551e831191f18734a2902559f33346d0e0.zip
Fix bug #1091189 (GUI: Launcher List/Edit game interaction)
svn-id: r16326
Diffstat (limited to 'gui/dialog.cpp')
-rw-r--r--gui/dialog.cpp48
1 files changed, 30 insertions, 18 deletions
diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index 6e00c2f005..95a8b804f5 100644
--- a/gui/dialog.cpp
+++ b/gui/dialog.cpp
@@ -36,6 +36,11 @@ namespace GUI {
* ...
*/
+Dialog::Dialog(int x, int y, int w, int h)
+ : GuiObject(x, y, w, h),
+ _mouseWidget(0), _focusedWidget(0), _clickedWidget(0), _visible(false) {
+}
+
Dialog::~Dialog() {
delete _firstWidget;
_firstWidget = 0;
@@ -114,15 +119,12 @@ void Dialog::drawDialog() {
void Dialog::handleMouseDown(int x, int y, int button, int clickCount) {
Widget *w;
w = findWidget(x, y);
+
+ _clickedWidget = w;
// If the click occured inside a widget which is not the currently
// focused one, change the focus to that widget.
- // TODO: use the wantsFocus() method to objects, so that only fields
- // that want it get the focus (like edit fields, list field...)
- // However, right now we "abuse" the focus also for the click&drag
- // behaviour of buttons. This should probably be changed by adding
- // a nother field, e.g. _clickedWidget or _dragWidget.
- if (w && w != _focusedWidget) {
+ if (w && w != _focusedWidget && w->wantsFocus()) {
// The focus will change. Tell the old focused widget (if any)
// that it lost the focus.
releaseFocus();
@@ -134,27 +136,28 @@ void Dialog::handleMouseDown(int x, int y, int button, int clickCount) {
_focusedWidget = w;
}
- if (w && w == _focusedWidget)
- _focusedWidget->handleMouseDown(x - (_focusedWidget->getAbsX() - _x), y - (_focusedWidget->getAbsY() - _y), button, clickCount);
+ if (w)
+ w->handleMouseDown(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button, clickCount);
}
void Dialog::handleMouseUp(int x, int y, int button, int clickCount) {
Widget *w;
+ w = findWidget(x, y);
+
if (_focusedWidget) {
- w = _focusedWidget;
+ //w = _focusedWidget;
// Lose focus on mouseup unless the widget requested to retain the focus
if (! (_focusedWidget->getFlags() & WIDGET_RETAIN_FOCUS )) {
releaseFocus();
}
-
- } else {
- w = findWidget(x, y);
}
- if (w)
+ if (w && w == _clickedWidget)
w->handleMouseUp(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button, clickCount);
+
+ _clickedWidget = 0;
}
void Dialog::handleMouseWheel(int x, int y, int direction) {
@@ -211,7 +214,10 @@ void Dialog::handleKeyUp(uint16 ascii, int keycode, int modifiers) {
void Dialog::handleMouseMoved(int x, int y, int button) {
Widget *w;
- if (_focusedWidget) {
+ //if (!button)
+ // _clickedWidget = 0;
+
+ if (_focusedWidget && !_clickedWidget) {
w = _focusedWidget;
int wx = w->getAbsX() - _x;
int wy = w->getAbsY() - _y;
@@ -220,6 +226,8 @@ void Dialog::handleMouseMoved(int x, int y, int button) {
// (but to no other items).
bool mouseInFocusedWidget = (x >= wx && x < wx + w->_w && y >= wy && y < wy + w->_h);
if (mouseInFocusedWidget && _mouseWidget != w) {
+ if (_mouseWidget)
+ _mouseWidget->handleMouseLeft(button);
_mouseWidget = w;
w->handleMouseEntered(button);
} else if (!mouseInFocusedWidget && _mouseWidget == w) {
@@ -231,6 +239,12 @@ void Dialog::handleMouseMoved(int x, int y, int button) {
}
w = findWidget(x, y);
+
+ // 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 (_clickedWidget && w != _clickedWidget) {
+ w = 0;
+ }
if (_mouseWidget != w) {
if (_mouseWidget)
@@ -240,11 +254,9 @@ void Dialog::handleMouseMoved(int x, int y, int button) {
_mouseWidget = w;
}
- if (!w || !(w->getFlags() & WIDGET_TRACK_MOUSE)) {
- return;
+ if (w && (w->getFlags() & WIDGET_TRACK_MOUSE)) {
+ w->handleMouseMoved(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button);
}
-
- w->handleMouseMoved(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button);
}
void Dialog::handleTickle() {